NPM package installation is divided into local installation (locally), the global installation of two, from the command line to see, the difference is only G-only, such as:
The code is as follows: Copy code
NPM Install # Local Installation
NPM INSTALL-G # Global Installation
explained separately below.
Global Installation:when NPM install XXX-G,
1. The module will be downloaded and installed into the global catalog.
2. Can be used directly on the command line
Note that the "Global Directory" is set by the NPM config set prefix "directory path", and the current settings directory is obtained through NPM config get prefix.
Local Installation:npm install XXX
1. Place the installation package under./node_modules (the directory where NPM is running)
2. A locally installed package can be introduced via require ()
For example:
C:\123>NPM Install XXX
will be installed to
C:\123\node_modules\xxx
This approach is obviously not good, so it is common to use the global installation of a unified installation of a directory, which is easy to manage, the structure is clear and can be reused.
Nodejs NPM Install differences between global and local installations