Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?
like image 750
OpenStack Avatar asked Jul 25 '16 14:07

OpenStack


People also ask

What is the command to install a node package globally for all the users in the system?

NPM installs global packages into /<User>/local/lib/node_modules folder. Apply -g in the install command to install package globally.

Does npm install packages globally?

When you install a package using npm you can perform 2 types of installation: a local install. a global install.

How do I use Global NPM packages?

To install a module from npm globally, you'll simply need to use the --global flag when running the install command to have the module install globally, rather than locally (to the current directory). Note: One caveat with global modules is that, by default, npm will install them to a system directory, not a local one.


1 Answers

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.
like image 199
Nick Avatar answered Oct 16 '22 10:10

Nick