0

I am setting up nexus npm repository, and created npm-group = npm-private+npm-registry (proxy to npm offical registry).

It comes to me thinking that if I publish my own package and name it say "jest" to my private repo, what happens if I do npm install jest? Does it take the private fake one or the one published in official site?

Thanks

void
  • 345
  • 3
  • 13

1 Answers1

2

You need to use scopes for your private packages. You prefix them with @yournamespace (for instance: "name": "@yournamespace/jest"), and you adjust your npmrc accordingly:

; Set a new registry for a scoped package
@yournamespace:registry=https://mycustomregistry.example.org

Using this scheme, you could use separate npm repositories, one for the proxy to the official npmjs repo, and one for your private packages.

Otherwise, if you override a package name, it will shadow the one that is proxified, so you will fetch your private package instead of the official one.

cghislai
  • 1,751
  • 15
  • 29
  • Thank you, I really like this approach, it gives me a peace of mind and don't need to worry about conflicts and you also answered me which one take precedence. Thank you! – void Feb 15 '20 at 02:25