Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
88
rated 0 times [  92] [ 4]  / answers: 1 / hits: 16731  / 4 Years ago, thu, march 26, 2020, 12:00:00

I am able to publish and install packages from my internal/private registry by configuring my .npmrc like so:



  $ npm config set registry https://mynpm-registry.com


However, I would like to configure my .npmrc to proxy out to public https://registry.npmjs.com/, if the package is not available in my internal regisry.



I understand that I can potentially configure multiple npm profiles - one for internal and one for external registry - like so:



$ npmrc -c my-internal-profile
$ npmrc -c my-external-profile


...but this is not what I am looking for. I would like to have a single .npmrc configuration, with both registries, that will proxy out to the public registry if I don't have a package available in my internal registry.



Is there anyway to do this?


More From » node.js

 Answers
34

One way you could do it is scoped packages in your .npmrc file.



Scoped Packages are simply put as the packages grouped under a namespace. You might have seen @angular/core or @react/something. So, these are the scoped packages.



In your .npmrc file, you could do the following



@yourorg:registry=http://localhost:4040/
registry=https://registry.npmjs.com


So, this basically means that you everything under @yourorg will be received from your registry, but others are going to be fetched from registry.npmjs.org.






If the first option doesn't solve what you are trying to do, you should look into https://help.sonatype.com/repomanager3/download



This is a registry manager where you can create private registries and create a group of registries (where one of them could be https://registry.npmjs.org). Then for npm, it would look like just a regular call but Sonatype does the heavylifting of :




  • If not found in your private registry, it looks to another registry you have mentioned.


[#51099] Tuesday, March 17, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hayleevalenciac

Total Points: 164
Total Questions: 89
Total Answers: 106

Location: Burkina Faso
Member since Thu, Dec 15, 2022
1 Year ago
;