Skip to content
Fix Code Error

Where does npm install packages?

March 13, 2021 by Code Error
Posted By: Anonymous

Can someone tell me where can I find the Node.js modules, which I installed using npm?

Solution

Global libraries

You can run npm list -g to see which global libraries are installed and where they’re located. Use npm list -g | head -1 for truncated output showing just the path. If you want to display only main packages not its sub-packages which installs along with it – you can use – npm list --depth=0 which will show all packages and for getting only globally installed packages, just add -g i.e. npm list -g --depth=0.

On Unix systems they are normally placed in /usr/local/lib/node or /usr/local/lib/node_modules when installed globally. If you set the NODE_PATH environment variable to this path, the modules can be found by node.

Windows XP – %USERPROFILE%AppDatanpmnode_modules
Windows 7, 8 and 10 – %USERPROFILE%AppDataRoamingnpmnode_modules

Non-global libraries

Non-global libraries are installed the node_modules sub folder in the folder you are currently in.

You can run npm list to see the installed non-global libraries for your current location.

When installing use -g option to install globally

npm install -g pm2 – pm2 will be installed globally. It will then typically be found in /usr/local/lib/node_modules (Use npm root -g to check where.)

npm install pm2 – pm2 will be installed locally. It will then typically be found in the local directory in /node_modules

Answered By: Anonymous

Related Articles

  • Design DFA accepting binary strings divisible by a number…
  • Easy interview question got harder: given numbers 1..100,…
  • Error message "Forbidden You don't have permission to access…
  • Having trouble with my nav bar/header, It used to work but…
  • Circle line-segment collision detection algorithm?
  • Why does the function named "traverse" not work on my code?
  • using d3.js with aurelia framework
  • Aurelia UX showcase app fails to load
  • Vue js vuecli3 application does not work in ie11 (babel is…
  • How do I install Java on Mac OSX allowing version switching?

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

How is Docker different from a virtual machine?

Next Post:

Is there a Boolean data type in Microsoft SQL Server like there is in MySQL?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Get code errors & solutions at akashmittal.com
© 2022 Fix Code Error