Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the default location for NPM installs on Windows?

Tags:

node.js

npm

When I install modules with NPM on Windows, it installs them to:

~/node_modules

I'd like to set change this to an arbitrary path such as:

c:\dev\repo\node_modules

I've tried

npm config set prefix <path>

With various values but none of them seem to work.

like image 293
cliff.meyers Avatar asked Mar 25 '12 13:03

cliff.meyers


People also ask

Where does npm install packages on Windows?

How does npm install packages globally? Global modules are installed in the /usr/local/lib/node_modules project directory in the standard system, which is the system's root. Print the location of all global modules on your system using this command.

Where does npm install itself?

zip. Extract this to the directory where NVM should be "installed". The default directory used by the installer is C:\Users\<username>\AppData\Roaming\nvm , but you can use whatever you like.

How do I change the location of a global node module?

js documentation and found that it can be changed very easily using a simple "npm config" command. For example: npm config set prefix "E:\node_modules", From the next time onward, every global installation will save the node modules in "E:\node_modules" folder.

Does npm install packages locally?

You can install a package locally if you want to depend on the package from your own module, using something like Node. js require . This is npm install 's default behavior.


1 Answers

As mentioned in the FAQ npm installs modules locally, to avoid dependency conflicts with nesting dependencies. If you really want different projects to reference the same copy you can use npm link.

like image 150
mtsr Avatar answered Sep 18 '22 15:09

mtsr