Home >Web Front-end >JS Tutorial >The difference between nodejs npm install global installation and local installation_node.js
npm package installation is divided into two types: local installation (local) and global installation (global). Judging from the command line, the difference is only whether there is -g, such as:
[Global directory] Set via npm config set prefix "directory path".
Get the currently set directory through npm config get prefix.
2. npm install xxx downloads the module to the directory where the current command line is located.
For example:
This method is obviously not good, so the global installation method is generally used to install it in a unified directory, which is convenient for management, has a clear structure, and can be reused.