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
Release: 2024-12-19 15:16:14
Original
819 people have browsed it

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

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

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

Viewing Global Directory:

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

npm root -g
Copy after login

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!

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