Discovering the Location of NPM-Installed Packages
npm, a package manager for Node.js, simplifies the installation of third-party modules. However, users may wonder where these modules reside after installation.
Locating Global Libraries
Global libraries, installed system-wide for all users, are typically stored in one of the following directories:
To view a truncated list of global libraries and their paths, execute the command:
npm list -g | head -1
For a more comprehensive list, including sub-packages, use:
npm list --depth=0
To filter the list to globally installed packages, add the -g flag:
npm list -g --depth=0
Windows users can expect to find global libraries in the following locations:
Locating Non-Global Libraries
Non-global libraries are installed within the node_modules subdirectory of the current working directory. To view the installed non-global libraries, execute:
npm list
Installing Packages Globally vs. Locally
By default, npm installs packages locally. To install a package globally, include the -g option:
The above is the detailed content of Where Do npm-Installed Packages Actually Live?. For more information, please follow other related articles on the PHP Chinese website!