gremo gremo - 6 months ago 41
Node.js Question

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

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

Everything you need is to read 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 c:\Program Files\nodejs\npmrc file, otherwise create/edit c:\Users\{username}\.npmrc.

But this change will have probably some side efects so read this discussion before. I think your idea is not a good one.

Comments