I recently found out that npm doesn’t support downloading same scope dependencies from multiple registries.

Ideally, I’d like to define multiple registries for a scope. If npm fails to find the package from registry1, then it should try registry2 and so on.

I use an @eisberg-labs scope for some private and some public packages.

Private packages are hosted on the github npm registry, and public on the npmjs.

Now, if I have an .npmrc saying


When downloading package with @eisberg-labs scope, npm will look no further than the configured registry, which is dissaponting.


Just publish a public package both to npmjs and github registry.

If anyone knows a better solution, please do share.

How to publish to a github npm registry

To be able to publish to a github private npm registry, add this to .npmrc:


Obtain a GITHUB_WRITE_PACKAGES_TOKEN by going to Settings -> Developer Settings -> Create new token and check write packages. Export the variable.

Note that .npmrc may be defined in your home or project directory.

As for installing from private npm registry, you’d define in project root an .npmrc with:


Publishing to a github npm registry is now easy as typing a npm publish.

Publish a public package to multiple registries

I first call npx release-it --dry-run and then without the --dry-run.

Then I go on to publish to the github registry.

npm config set _authToken=$GITHUB_WRITE_PACKAGES_TOKEN
npm login --registry=https://npm.pkg.github.com
npm publish --access public --@eisberg-labs:registry=https://npm.pkg.github.com
Categories: DevOpsProgramming

Notify of
Inline Feedbacks
View all comments