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 topackage.json
  • –devTo keep:package.jsondevDependenciesNode, not specified-devWill save to the dependent node

Note 1: The difference between a global installation and a non-global installation:

Global installation:

  • Installed in theC:\Users\Administrator\AppData\Roaming\npmdirectory
  • 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 directorynode_modulesfolder

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

  1. Update a single plug-in
npm update <name> [ -g ] [ --save-dev ]
Copy the code
  1. Update all plug-ins
npm update [ --save-dev ] 
Copy the code

NPM Other commands

  1. Check that plug-ins are installed in the current directory
    npm list
    Copy the code
  2. View the version of the current installation package
    npm ls <name>
    Copy the code
  3. Changed the download image source
    npm config setRegistry changes to https://registry.npm.taobao.org NPM mirror download for taobao imageCopy the code