Front-end (vue) entry to mastery course: enter to learn
npm get registry
npm config set registry https://registry.npmmirror.com
old http://npm.taobao.org and http://registry.npm.taobao The .org domain name will cease service from 0:00 on May 31, 2022. So don’t use the old command:
npm config set registry http://registry.npm.taobao.orgRestore
npm config set registry https://registry.npmjs.orgUse
# Install nrm globally npm install -g nrm # View nrm source list (supports default source, Taobao source, Tencent source, etc.) nrmls # Switch source (the name of the mirror source can be seen by nrm ls) nrm use taobao
registry = https://registry.npmmirror.com
Global installation
#Install the latest version npm install -g xxx #Install the specified version npm install -g [email protected]
npm install xxx
npm install -S xxx # Same effect as above, default: npm install xxx
npm install –D xxx
npm install [email protected]
npm install --registry=https: //registry.npmmirror.com
npm install [email protected] --registry=https://registry.npmmirror.com
Uninstall
npm uninstall <package-name>
npm uninstall -S <package-name> npm uninstall -D <package-name>
npm uninstall -g <package-name>
npm uninstall -S <package-name> # Equivalent to npm remove -S <package-name> # Equivalent to npm rm -S <package-name>
First check to update
npm outdated
Packages marked in red are updateable, and packages marked in yellow are non-updateable.
npm update
# 1. Install the "npm-check-updates" module npm install -g npm-check-updates # 2. Check the updateable module ncu npm-check-updates # Both of the above two commands can check updateable modules. Next, update the package.json dependency package to the latest version: #Upgrade all versions in the dependencies and devDependencies of the package.json file ncu -u #Execute the above command to update all modules. However, in actual development, it is not recommended to update all at once. You can update the specified modules according to actual needs, and you can add -D, -S or -g at the end according to the scope.
Method 2:
# Install npm-check globally. npm install -g npm-check # Check updateable dependencies npm-check # Update dependencies npm-check -u
# Another way to update the main version is to uninstall first and then reinstall # Uninstall npm uninstall xxx # Reinstall-latest version npm install xxx # Reinstall-Specify the version npm install [email protected]
View npm version
npm -v
View installed package version
npm package name -v
View npm help
npm help
View all folders used by npm
npm help folders
View module list (view the list of locally installed modules)
npm list # You can also use the abbreviation ls npm ls
to view globally installed packages
npm list -g --depth 0
npm list vue-cli
to view the package.json folder of the node module
npm view moduleNames
npm view moudleName dependencies
to view the package's Source file address
npm view moduleName repository.url
View the version of Node on which the package depends
npm view moduleName engines
View the installation path of the current package
npm root
View the installation path of the global package
npm root -g
Check whether the package is outdated
This command will list all Outdated packages can be updated in time.
npm outdated
accesses npm's json folder.
An npm package is a folder that contains package.json. package.json describes the structure of this folder. The method to access npm's json folder is as follows:
npm help json
This command will open a web page in the default way. If the default opening program is changed, it may not open as a web page.
Check whether the package name already exists.
When publishing an npm package, you need to check whether a certain package name already exists
npm search packageName # You can also use the abbreviation s instead of search npm s packageName
npm cache clean # Clear npm cache npm prune # Clear unused packages in the project npm outdated # Check whether the module is outdated npm repo jquery # Will open the default browser and jump to the jquery page in github npm docs jquery # Will open The default browser jumps to the README.MD file information of jquery in github npm home jquery # The default browser will be opened to jump to the homepage of jquery in github
The npm version number format XYZ
represents: major version number.minor version number.revision number. The increment rules
of
the
Backward compatible functionality is added,
Z. Revision number: When you make a backward compatible issue fix.
1.0.0 It is a 100% match. The current library/project must use the current version number. If the same library and different versions are used for other dependencies, a node_modules folder will be created under the library folder to store the version files it needs to depend on.
does not change the major version number and minor version number. The revision number can be changed at will. For example, ~2.0.0, you can use versions 2.0.0, 2.0.2, and 2.0.9.
does not change the major version number (the major version number is not 0). This version number and revision number can be changed at will. For example, ^2.0.0, you can use versions 2.0.1, 2.2.2, and 2.9.9.
* means that any version has no restrictions on the version. Generally, "base": "*" is notused.
is greater than a certain version, which means that as long as the installation package is greater than this version, it will be fine. For example: "node": "> 4.0.0"
is greater than a certain version, it means that any installation package that is greater than or equal to this version will be fine. For example: "node": ">= 4.0.0"If
is less than a certain version, it means that any installation package that is smaller than this version will be fine. For example: :"http-proxy-middleware": "<0.17.3"
is less than or equal to a certain version, which means that as long as the installation package is less than or equal to this version, it will be fine. For example: "http-proxy-middleware": "<= 0.17.3"
-indicates the version between the two version numbers "base": "1.0.1-1.5.9" For example, 1.0.1-1.5.9 can use any version between 1.0.1 to 1.5.9