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?
You should use this command to set the global installation flocation of npm packages
(git bash)
npm config --global set prefix </path/you/want/to/use>/npm
(cmd/git-cmd)
npm config --global set prefix <drive:\path\you\want\to\use>\npm
You may also consider the
npm-cache
location right next to it. (as would be in a normal nodejs installation on windows)(git bash)
npm config --global set cache </path/you/want/to/use>/npm-cache
(cmd/git-cmd)
npm config --global set cache <drive:\path\you\want\to\use>\npm-cache
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 changeprefix
toc:\Program Files\nodejs
in your config file. If you want to change it globally for all users, editc:\Program Files\nodejs\npmrc
file, otherwise create/editc:\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.
it does not require much configurations just go to advanced system settings copy the path where you have installed your node and just create an environment variable and check with node -v command in your prompt!
Using a Windows symbolic link from the C:\Users{username}\AppData\Roaming\npm and C:\Users{username}\AppData\Roaming\npm-cache paths to the destination worked great for me.
How to add a symbolic link
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 locationnpm 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.10Delete node folder completely from program file folder. Uninstall node.js and then reinstall it. change Path of environment variable PATH. delete .npmrc file from C:\users\yourusername