Where does npm install packages?

How to find out where npm installs packages

readnpm guideIf you start with npm, it will involve a lot of basic details.

When you use the installation packagenpm(oryarn), you can perform 2 types of installation:

  • Local installation
  • Global installation

By default, when you typenpm installCommand, for example:

npm install lodash

The package is installed in the current file treenode_modulessubfolder.

When this happensnpmAlso addedlodashenterdependenciesAttribute ofpackage.jsonfileExists in the current folder.

Use the following command to perform a global installation-gbanner:

npm install -g lodash

When this happens, npm does not install the package in a local folder, but uses a global location.

Where is it?

Thisnpm root -gThe command will tell you where the exact location is on your computer.

On macOS or Linux, this location may be/usr/local/lib/node_modules. On Windows may beC:\Users\YOU\AppData\Roaming\npm\node_modules

If you usenvmManage the Node.js version, but the location will be different.

Let me give an examplenvmMy package location is displayed as/Users/flavio/.nvm/versions/node/v8.9.0/lib/node_modules.

Download mine for freeNode.js manual

More node tutorials: