Search code examples
npmnexus

How do you setup npm to lookup public registry and local nexus registry?


I'm having an issue where I created a local nexus registry with a package. I am unable to run npm install where it grabs the public packages and my private ones accordingly.

I've tried adding the lines seperately in my .npmrc file individually and it works for the private but fails for public. And then vice versa if I switch the lines in the npmrc files. I can't get both to work at same time. Any ideas?

I tried:

registry=https://registry.npmjs.org
@myRegistry:registry=http://192.168.0.245:8082/repository/abc
404 Not Found - GET https://registry.npmjs.org/my-websocket-library - Not found

(This will work if I remove the public registry but will fail on public packages)

And as I mentioned just registry = for both by itself and it works for the specific packages but fails on the others ones.


Solution

  • The part after the @ specifies that only packages under that scope will go to the private repo.

    So if your my-websocket-library was instead called @myregistry/my-websocket-library it would work.

    It's good practice anyway to scope the packages like this so it's clear what is private and what isn't. So you should adopt a naming strategy.