cnpm

The default NPM mirror storage is in foreign countries, then Taobao mirror every 10 minutes and the official synchronization, s so we can use Taobao mirror, so the download speed is faster

Installation steps:

$ npm install -g cnpm --registry=https://registry.npm.taobao.org
Copy the code

nrm

NRM is a warehouse management tool

NRM ls / / can view all the storage (a * is the current storage) * CNPM NPM - https://registry.npmjs.org/ - http://r.cnpmjs.org/ taobao https://registry.npm.taobao.org/ nj ----- https://registry.nodejitsu.com/ rednpm - http://registry.mirror.cqupt.edu.cn/ npmMirror https://skimdb.npmjs.com/registry/ edunpm - http://registry.enpmjs.org/ nrmtest// Can test each warehouse to your local speed NRM use taobaoCopy the code

npm

NPM is node Package Manager

NPM manages node modules, such as uploading, downloading, updating, and initialization

Some commands:

NPM init initializes, creating a package.json fileCopy the code

Here’s an example: When we run NPM init –yes (–yes means I don’t configure anything, just give me the simplest package.json file), we get a package.json file that looks like this

{
  "name": "npm-demo"."version": "1.0.0"."description": ""."main": "index.js", (the entry file representing the module is index.js)"scripts"Scripts contains various commands that you can define with different names. The common one is NPM runtest, NPM run dev, NPM run build, etc.)"test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": []."author": ""."license": "ISC"
}
Copy the code

The script command can be found in the official documentation

The package.json file is currently installed without any modules. If a module is installed, the package.json file will change, for example, when we run it

npm install mockjs
Copy the code

At this point, package.json becomes

{
  "name": "npm-demo"."version": "1.0.0"."description": ""."main": "index.js"."scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": []."author": ""."license": "ISC"."dependencies": {
    "mockjs": "^ -beta3 1.0.1"}}Copy the code

In Dependencies is the module we installed

So we know that if we add –save-dev, it means partial installation, so what’s the difference after installation? So let’s just run it

npm install webpack --save-dev
Copy the code

Json, “devDependencies” after “dependencies”, contains the webpack we installed

 "dependencies": {
    "mockjs": "^ -beta3 1.0.1"
  },
  "devDependencies": {
    "webpack": "^ 4.16.5"
  }
Copy the code