OpenStack
OpenStack

Reputation: 5596

Making Global NPM packages available to all users on windows 2012 server

I am trying to install continues integration server. This server will pull data from GIT and it will try to build the application. Since I am using windows 2012 server, multiple users can trigger the build. For this purpose, I want to ensure all the node packages I install as admin are available to all users.

How can I:

  1. Install node packages globally that are available to all users.
  2. I want to use a locally hosted node registry. I don't want to use node registry.
  3. After the installing the packages, how can I validate if all users can access the packages?

Upvotes: 42

Views: 39984

Answers (4)

foxontherock
foxontherock

Reputation: 1842

I had the same problem, I need gulp to be global for all users, and for teamcity that is running under localsystem.

This is my solution: (from a fresh new setup, right after installing node) on an "admin" command prompt

  1. npm install --global gulp-cli
  2. where gulp (response is: C:\Users\MYUSER\AppData\Roaming\npm\gulp)
  3. open exlorer, go in that folder, and move all (gulp, gulp.cmd, node_modules that contains gulp-cli) to "C:\Program Files\nodejs"

And it works, now, gulp is global to all users, like npm.

Upvotes: 0

oren beeri
oren beeri

Reputation: 251

For the 'Network Service' account use the folder:

C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\npm

Upvotes: 25

Nick
Nick

Reputation: 5198

Had the same issue. Needed the CI build agent to run a global package on the CLI. Saw this post in a new feature request for system-wide npm -g for Windows.

In short:

  1. Open an administrator level command prompt
  2. Note the current global prefix: npm prefix -g
  3. Set the global prefix to the CI user: npm config set prefix <C:\Users\CI_USER\AppData\Roaming\npm>
  4. Install the needed packages: npm i -g PKG
  5. Restore the prefix to the previous value.

Upvotes: 65

Tony Yip
Tony Yip

Reputation: 750

You can add a global environment variable NODE_PATH to set the package require search path. You may see here for more. https://gist.github.com/branneman/8048520#4-the-environment

Upvotes: 1

Related Questions