npm common command instructions

npm is the abbreviation of node package manager, which means node package manager. It is a tool used to manage various project packages in node.

1. npm install

This command is used to install the dependency packages required in the project, that is, all the keys under dependencies and devDependencies in the package.json file. The value corresponding to the key is the version of the dependency. Executing npm install will install all dependencies to the node_modules folder.

2. npm install + name

This command specifies a package that needs to be installed locally. Only the specified dependencies will be installed.

3. npm install -g + name

This command specifies a package that needs to be installed globally

4. npm install -save + name

This command specifies a package that requires local production installation, that is, installed in dependencies

5. npm install -save-dev + name

This command specifies a package that requires local development installation, that is, installed in devDependencies .

6. npm uninstall + name

This command specifies a package to be uninstalled

Appendix 1. The difference between dependencies and devDependencies

The dependencies installed in dependencies will be packaged with the project and are part of the production environment. That is, you borrowed other people's code, such as jquery.

The dependencies installed in devDependencies will not be packaged with the project. They only belong to the development environment and play a role during packaging and compilation, that is, code optimization, such as node-sass.

Appendix 2. Abbreviation

npm install abbreviated as npm i

npm install -save abbreviated as npm i -S

npm install -save-dev abbreviated as npm i -D

npm uninstall is abbreviated as npm un

Guess you like

Origin blog.csdn.net/jl15988/article/details/120221880