I'm testing a new version of our npm packages registry. I'd like to run a job in our CI server specifying a registry different of the default.
I tried to execute npm publish --registry "http://nexus.dsv.myhost/nexus/repository/npmjs-registry
but it didn't work. It was published to the default registry.
How do I specify a different registry while running npm publish
. It is a scoped package.
It sounds like you have a scope-specific registry configured somewhere in your npm config.
npm will merge your global, local and CLI-provided config. But any scope-specific config will take precedence over unscoped config regardless of where each of them are defined.
For example, if you have @myscope:registry=xyz
in your ~/.npmrc
file, that will take precedence over --registry=abc
provided on the CLI, because a scope-specific registry always overrides the unscoped registry.
However, you can also pass a scope-specific registry on the CLI itself like this:
npm publish --@myscope:registry=http://nexus.dsv.myhost/nexus/repository/npmjs-registry
Note that because of how nopt
(which is what npm uses under the hood to parse the CLI options) parses freeform switches, the =
sign here is required. If you use a space instead, it won't work as expected.