NPM (Node Package Manager) is the node.js Package Manager used for Node plug-in management (install, uninstall, manage dependencies, etc.).
CNPM, NPM image of Taobao source. Because the NPM installation plug-in is downloaded from a foreign server, which is affected by the network and prone to abnormalities, so the Taobao team made a complete image of nPMjs.org, which is synchronized with the official service frequency every 10 minutes. CNPM supports all NPM commands except publish, so you can safely use CNPM instead of NPM.
Install the NPM plug-in
npm install <name> [-g] [--save-dev]
Copy the code
- <name>: Indicates the name of a node plug-in
- -g: Global installation
- –save: will save to
package.json
中 - –devTo keep:
package.json
的devDependencies
Node, not specified-dev
Will save to the dependent node
Note 1: The difference between a global installation and a non-global installation:
Global installation:
- Installed in the
C:\Users\Administrator\AppData\Roaming\npm
directory- The system environment variable is written and can be invoked from anywhere on the command line
Non-global installation:
- Will be installed in the current location directory
node_modules
folder
Note 2: Why save to package.json
Because the node plug-in package is relatively large, instead of versioning it, write the configuration information to package.json and add it to versioning. Other developers can download it accordingly (NPM install at the command prompt will download all required packages according to package.json).
2. Uninstall the NPM plug-in
npm uninstall <name> [ -g ] [ --save-dev ]
Copy the code
NPM update plugin
- Update a single plug-in
npm update <name> [ -g ] [ --save-dev ]
Copy the code
- Update all plug-ins
npm update [ --save-dev ]
Copy the code
NPM Other commands
- Check that plug-ins are installed in the current directory
npm list Copy the code
- View the version of the current installation package
npm ls <name> Copy the code
- Changed the download image source
npm config setRegistry changes to https://registry.npm.taobao.org NPM mirror download for taobao imageCopy the code