npm introduction and cnpm introduction

Introduction to npm

  1. Description: npm (node ​​package manager) is the package manager of nodejs, used for node plugin management (including installation, uninstallation, management of dependencies, etc.)
  2. Install the plugin using npm: command prompt execute npm install <name> [-g] [--save-dev] 
    <name>: node plugin name. 
    example:npm install gulp-less --save-dev

-g: Install globally. 
It will be installed in C:\Users\Administrator\AppData\Roaming\npm, and written to the system environment variable; non-global installation: it will be installed in the current location directory; global installation can call it anywhere through the command line, local installation It will be installed in the node_modules folder of the location directory and called by require();

--save: save the configuration information to package.json (package.json is the nodejs project configuration file);

-dev: Save to the devDependencies node of package.json, if -dev is not specified, it will be saved to the dependencies node;

Why save to package.json? Because the node plug-in package is relatively large, version management is not added, and the configuration information is written into package.json and added to version management. Other developers can download it accordingly (execute npm install at the command prompt, and the package .json to download all required packages).

3. Use npm to uninstall plugins: npm uninstall <name> [-g] [--save-dev] 
PS: Do not delete the local plugin package directly 
4. Use npm to update plugins: npm update <name> [-g] [--save-dev] 
5. Update all plugins: npm update [--save-dev] 
6. View npm help: npm help 
7. View installed plugins in the current directory:npm list

PS: The process of installing plug-ins with npm: Download the corresponding plug-in package from http://registry.npmjs.org (the website server is located abroad, so the download is often slow or abnormal). See the solution below ↓↓↓↓↓↓.

Optional cnpm

 

 

  1. Note: Because the npm installation plugin is downloaded from a foreign server, it is greatly affected by the network and may be abnormal. It would be fine if the npm server was in China, so the Taobao team we are happy to share did this. From the official website: "This is a complete npmjs.org mirror. You can use this instead of the official version (read-only). The synchronization frequency is currently once every 10 minutes to ensure that it is synchronized with the official service as much as possible."
  2. Official website: http://npm.taobao.org
  3. Installation: command prompt executionnpm install cnpm -g --registry=https://registry.npm.taobao.org
  4. Note: After installation, it is best to check its version number cnpm -v or close the command prompt and reopen it, there may be errors when using it directly after installation 

 

Note: The usage of cnpm is exactly the same as that of npm, except that npm is changed to cnpm when executing the command.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326347097&siteId=291194637
Recommended