Home > Web Front-end > JS Tutorial > Where Do npm-Installed Packages Actually Live?

Where Do npm-Installed Packages Actually Live?

Patricia Arquette
Release: 2024-11-29 19:07:15
Original
480 people have browsed it

Where Do npm-Installed Packages Actually Live?

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:

  • Unix systems: /usr/local/lib/node or /usr/local/lib/node_modules

To view a truncated list of global libraries and their paths, execute the command:

npm list -g | head -1
Copy after login

For a more comprehensive list, including sub-packages, use:

npm list --depth=0
Copy after login

To filter the list to globally installed packages, add the -g flag:

npm list -g --depth=0
Copy after login

Windows users can expect to find global libraries in the following locations:

  • Windows XP: %USERPROFILE%AppDatanpmnode_modules
  • Windows 7, 8, and 10: %USERPROFILE%AppDataRoamingnpmnode_modules

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
Copy after login

Installing Packages Globally vs. Locally

By default, npm installs packages locally. To install a package globally, include the -g option:

  • npm install -g pm2: Installs pm2 globally, typically placing it in /usr/local/lib/node_modules.
  • npm install pm2: Installs pm2 locally, placing it in the current directory's node_modules subdirectory.

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template