Differences between nodejs NPM install and local install
- 2020-03-30 03:10:56
- OfStack
Package installation of NPM is divided into local installation and global installation. From the command line, the difference is only with or without -g, for example:
npm install grunt # The local installation
npm install -g grunt-cli # Global installation
Here's how.
1. When NPM install xxx-g, the module will be downloaded and installed into the [global directory].
Global directory is set by NPM config set prefix "directory path".
Get the currently set directory through NPM config get prefix.
2. NPM install XXX is to download the module to the directory where the current command line is located.
Such as:
c:123>npm install xxx
Will be installed into
c:123node_modulesxxx
This way is obviously not good, so generally will use the global installation method to install a directory to go, which is easy to manage, the structure is clear and can be reused.