Change default global installation directory for node.js modules in Windows?
trying to install global packages into C:\Program Files (x86)\nodejs\
gave me Run as Administrator issues, because npm was trying to install intoC:\Program Files (x86)\nodejs\node_modules\
to resolve this, change global install directory to C:\Users\{username}\AppData\Roaming\npm
:
in C:\Users\{username}\
, create .npmrc
file with contents:
prefix = "C:\\Users\\{username}\\AppData\\Roaming\\npm"
reference
npm install -g package
installs global packages into prefix location- npmrc userconfig takes priority and overrides
npm config ls -l
was showingprefix = "C:\\Program Files (x86)\\nodejs"
environment
nodejs x86 installer into C:\Program Files (x86)\nodejs\
on Windows 7 Ultimate N 64-bit SP1node --version
: v0.10.28npm --version
: 1.4.10
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.