Building on the installation concept of chocolatey
and the idea suggested by @Tracker, what worked for me was to do the following and all users on windows were then happy working with nodejs
and npm
.
Choose C:\ProgramData\nodejs
as installation directory for nodejs
and install nodejs
with any user that is a member of the administrator group.
This can be done with chocolatey as: choco install nodejs.install -ia "'INSTALLDIR=C:\ProgramData\nodejs'"
Then create a folder called npm-cache
at the root of the installation directory, which after following above would be C:\ProgramData\nodejs\npm-cache
.
Create a folder called etc
at the root of the installation directory, which after following above would be C:\ProgramData\nodejs\etc
.
Set NODE
environment variable as C:\ProgramData\nodejs
.
Set NODE_PATH
environment variable as C:\ProgramData\nodejs\node_modules
.
Ensure %NODE%
environment variable previously created above is added (or its path) is added to %PATH%
environment variable.
Edit %NODE_PATH%\npm\npmrc
with the following content prefix=C:\ProgramData\nodejs
From command prompt, set the global config like so...
npm config --global set prefix "C:\ProgramData\nodejs"
npm config --global set cache "C:\ProgramData\nodejs\npm-cache"
It is important the steps above are carried out preferably in sequence and before updating npm (npm -g install npm@latest
) or attempting to install any npm
module.
Performing the above steps helped us running nodejs
as system wide installation, easily available to all users with proper permissions. Each user can then run node
and npm
as required.