MrSimonEmms
MrSimonEmms

Reputation: 1481

Can I choose where to publish my NPM module - either to the public or a private repo?

We have recently started using a private NPM repository at work. I also write various modules that are hosted in the main public NPM repo. The private repo does NOT replicate up (it just replicates down). Is there any way to specify to which repository I want to publish an NPM package?

Naturally, I want to publish work stuff to our private NPM repository and open-source modules to the public repository.

My ~/.npmrc file looks similar to this (obviously, values are taken out)

_auth = AUTH_TOKEN
email = MY_EMAIL
registry = URL_FOR_PRIVATE_REPO

Having done a bit of Googling, I found things like this, but it does seem rather out-of-date (it's closed 2 years ago).

Upvotes: 0

Views: 186

Answers (1)

isaacs
isaacs

Reputation: 17160

In the package.json file:

{
  "publishConfig": {
    "registry":"https://private.internal.registry.mycompany.local/"
  }
}

The npmrc stuff is a bit tricky to manage. We're working on rewriting a bunch of stuff so that all those configs will be scoped to a specific registry, but it'll be a while before that's done.

Upvotes: 2

Related Questions