Home >Web Front-end >JS Tutorial >Where Are My npm-Installed Node.js Modules Located?

Where Are My npm-Installed Node.js Modules Located?

Susan Sarandon
Susan SarandonOriginal
2024-12-19 15:16:14849browse

Where Are My npm-Installed Node.js Modules Located?

Locating Node.js Modules Installed with npm

Introduction:

When installing packages using npm, it's essential to be aware of their location. This knowledge allows developers to troubleshoot issues, access documentation, and manage dependencies effectively.

Global Modules:

To view the list of globally installed Node.js modules, execute the following command:

npm list -g

These modules are typically installed in the following directories:

  • Unix systems: /usr/local/lib/node or /usr/local/lib/node_modules
  • Windows XP: %USERPROFILE%AppDatanpmnode_modules
  • Windows 7, 8, and 10: %USERPROFILE%AppDataRoamingnpmnode_modules

Non-Global Modules:

Packages installed without the -g (global) flag are non-global modules. These are stored in a subfolder named node_modules within your current working directory.

To view a list of non-global modules, run the command:

npm list

Installing Globally:

To ensure a module is installed globally, use the -g option during installation, as seen in the example below:

npm install -g pm2

Viewing Global Directory:

To confirm the location of globally installed modules, execute the following command:

npm root -g

The above is the detailed content of Where Are My npm-Installed Node.js Modules Located?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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
Previous article:Some WEB structuresNext article:Some WEB structures