Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing npm packages from multiple registries

Tags:

npm

Working on a project where I need to install npm packages from several registries - the default npm registry and several custom registries.

My existing solution is to use npm scripts to break the install into steps which use the --registry flag. Something like this:

"install-pkg1":   "npm install pkg1 --registry https://pkg1.domain.com",
"install-pkg2":   "npm install pkg2 --registry https://pkg2.domain.com",
"install-custom": "npm install && npm run install-pkg1 && npm run install-pkg2"

Then use npm run install-custom in place of npm install to install all the dependencies.

Is there a more preferred method for installing packages from multiple registries?

As noted in the comments below, there is a discussion on Github about this.

like image 693
Brett DeWoody Avatar asked Oct 27 '16 15:10

Brett DeWoody


People also ask

Can we have multiple registry in Npmrc file?

If you have certs for the respective registries, you can add multiple certs to your . npmrc file.

How many packages are there in npm registry?

The free npm Registry has become the center of JavaScript code sharing, and with more than one million packages, the largest software registry in the world.

What is Verdaccio npm?

Verdaccio is a simple, zero-config-required local private npm registry. No need for an entire database just to get started! Verdaccio comes out of the box with its own tiny database, and the ability to proxy other registries (eg. npmjs.org), caching the downloaded modules along the way.


1 Answers

This is pretty much one of the reasons for npm ci. The registries and versions will be defined there so you shouldnt need to do anything crazy to get them all from their corresponding registries. Also, this can kind of be accomplished with scopes, where you associate a registry with a scope, but this requires you publishing the packages scoped as whatever. more info on associating registry with scopes

like image 194
jumpdart Avatar answered Sep 24 '22 08:09

jumpdart