21

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

Below are the two repositories 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 on StackOverflow for this similar problem, but those solution is suggesting to used scoped package approach. I don't want to use the scoped package approach for configuring multiple repositories in a npmrc file.

I have already gone through the solution available on Is there any way to configure multiple registries in a single npmrc file But I am looking for a different approach, where I can define multiple repositories with its priority in npmrc file.

I request not to mark this question as closed without giving a satisfactory correct answer.

Thanks.

user2068260
  • 373
  • 1
  • 3
  • 10

1 Answers1

8

As far as I know you can not define multiple NPM registry URLs in .npmrc , on the CLI, or anywhere else, and have NPM check them based on priority.

Configure your NPM server to check for a requested package locally first and fall back to the public NPM registry if not found. This can be done with Nexus, and I believe Sinopia/Verdaccio do this out of the box.

Dan O
  • 6,022
  • 2
  • 32
  • 50
  • There is a similar question and good answer here https://stackoverflow.com/questions/48417082/how-to-config-several-private-repository-and-public-repository-in-npm/48417335#48417335 – Juan Picado Jan 26 '18 at 10:23