Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the default path for node modules?

Tags:

node.js

npm

I have installed node.js at my local system (path : C:\Program Files\nodejs). I installed some modules and expected them to be placed in (C:\Program Files\nodejs\node_modules). But, the installed modules are placed at C:\Users\Administrator\AppData\Roaming\npm\node_modules. Is this right or wrong? Can i access these modules globally?

My system platform is windows 7, and my version of node is 0.10.

like image 398
Harsan Avatar asked Aug 01 '26 10:08

Harsan


1 Answers

The current (January 2018) version of Node.js is 9.4.0, so I'm not sure if it is compatible with your version.

You can set the default global installation path for node_modules by modifying your npmrc file.

Execute in a prompt: npm config list. It should among other things display a prefix setting, which is set to your Roaming AppData folder, for example: C:\Users\Administrator\AppData\Roaming\npm. You can override this setting by executing npm config set prefix C:\Program Files\nodejs\node_modules\npm.

Now, once you install node_modules globally they will be placed in that directory.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!