How to use multiple repository sources with priority in NPM?

Asked

Viewed 51 times

5

I know it is possible to use local records with the command

npm config set registry <registry url>

However, as I understand it, this command changes the NPM to search only in that repository.

I also read about scoped packages, But from what I understand, it would only use my repository when I expressly stated that that package is in my repository and, if it was not found, I would say that it was not possible to install. Only what I wanted to do was try to search my local repository and, if not found on it, search the NPM repository (https://registry.npmjs.org/).

I was wondering if it’s possible to make a npm install with this priority order from where he gets the packages?

  • Stop being lazy Felipe, hahahaha. #hugs

1 answer

3


So far it is not possible, according to the documentation. I have also read a lot of the documentation in search of this solution. A possible solution is to use the Nexus as local NPM repository and set up a proxy for public NPM. It will have exactly the behavior you want:

...search in my local repository and, if not found in it, search the NPM repository

Basically if the Nexus does not locate the desired package in its local repository it will fetch it in public NPM and cache it locally.

Another reference on this solution: https://medium.com/react-redux-best-practice/establishing-private-npm-repository-over-nexus-7a45d9f1cf0d

Browser other questions tagged

You are not signed in. Login or sign up in order to post.