How to define a backup registry in a global .npmrc file

I have a private registry configured in my global .npmrc file. Now I want to configure the backup registry also in the same npmrc file. When npm cannot find the module in my private repository, I want it to load it from the npm global registry, i.e. https://registry.npmjs.org

Below are two repositories that I want to configure:

http://devint:9999/nexus/content/groups/NPM-Release   //npm should first look into this

https://registry.npmjs.org // fallback registry

I know there is a solution available in StackOverflow for this similar problem, but this solution suggests using a limited package approach. I do not want to use a batch approach to configure multiple repositories in the npmrc file.

I already examined the solution available on Is there a way to configure multiple registries in a single npmrc file But I'm looking for a different approach where I can define multiple repositories with its priority in the npmrc file.

I ask you not to mark this question as closed, without giving a satisfactory correct answer.

Thank.

+4
source share
1 answer

As far as I know, you cannot define multiple NPM registry URLs in .npmrc, in the CLI, or elsewhere, and NPM checks them based on priority.

Configure your NPM server to check the local package first and then return to the public NPM registry if it is not found. This can be done with Nexus , and I believe that Sinopia / Verdaccio do it out of the box.

+2

Source: https://habr.com/ru/post/1690978/


All Articles