Change default global installation directory for node.js modules in Windows?

gremo picture gremo · Nov 9, 2013 · Viewed 278.4k times · Source

In my windows installation PATH includes C:\Program Files\nodejs, where executable node.exe is. I'm able to launch node from the shell, as well as npm. I'd like new executables to be installed in C:\Program Files\nodejs as well, but it seems impossible to achieve.

Setting NODE_PATH and NODE_MODULES variables doesn't change anything: things are still installed in %appdata%\npm by default.

How can I change the global installation path?

Answer

ivoszz picture ivoszz · Nov 9, 2013

Everything you need is in the npm-folders documentation. I don't want to start my Win notebook now so I cannot verify it, but you should only change prefix to C:\Program Files\nodejs in your config file. If you want to change it globally for all users, edit the C:\Program Files\nodejs\npmrc file, otherwise create/edit C:\Users\{username}\.npmrc.

But this change will probably have some side effects, so read this discussion first. I don't think it's a good idea.