Npm package installation can be divided into local installation and global installation. from the command line, the difference is-g. For example:
Copy codeThe Code is as follows:
Npm install grunt # local Installation
Npm install-g grunt-cli # global installation
The following are explanations.
1. When npm install xxx-g, the module will be downloaded and installed to the global directory.
[Global Directory] is set through npm config set prefix "directory path.
Use npm config get prefix to obtain the directory currently set.
2. npm install xxx is to download the module to the directory where the current command line is located.
For example:
Copy codeThe Code is as follows: c :\123> npm install xxx
Will be installed
Copy codeThe Code is as follows: c: \ 123 \ node_modules \ xxx
This method is obviously not good, so the global installation method is generally used in a unified directory for installation, which facilitates management, clear structure, and can be reused.