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.
If you have certs for the respective registries, you can add multiple certs to your . npmrc file.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With