First introduce npm
The full name of NPM is Node Package Manager, which is a NodeJS package management and distribution tool, and has become an unofficial standard for releasing Node modules (packages).
The main functions are these
- Allows users to download third-party packages written by others from the NPM server for local use.
- Allows users to download and install command-line programs written by others from the NPM server for local use.
- Allows users to upload their own packages or command-line programs to the NPM server for others to use.
Now list some npm commands
- It can detect whether the installation is successful node and node -v have the same effect
npm -v
- Commands for using Taobao Mirror
npm install -g cnpm --registry=https://registry.npmmirror.com
- Install Node.js module syntax format
npm install
where install is equivalent to add, i, in, ins, inst, insta, instal, isnt, isnta, isntal
- Local installation and global installation (take jquery as an example)
npm i jquery
npm i jquery -g
- View all globally installed modules
npm list -g
- Check the version number of a module
npm list grunt
- Uninstall the module (take jquery as an example)
npm uninstall jquery
where uninstall is equivalent to unlink, remove, rm, r, un
- Check if the package exists
npm ls
- Update module (take jquery as an example)
npm update jquery
- Explore modules (take jquery as an example)
npm search jquery
- View historical versions (take jquery as an example)
npm view jquery versions
Supplement
View the global installation directory
npm root view -g
Both during development and on-line development
npm i jquery -D
npm i jquery -S
Install the specified version
npm i pkg@version
The last important thing is to view the command help
npm help
That concludes the summary here, see you next time!!!