Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM: how to specify registry to publish in the command line?

Tags:

npm

nexus3

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.

like image 855
neves Avatar asked Aug 23 '19 21:08

neves


People also ask

What is npm publish command?

Publishes a package to the registry so that it can be installed by name. By default npm will publish to the public registry. This can be overridden by specifying a different default registry or using a scope in the name, combined with a scope-configured registry (see package. json ).


1 Answers

There's multiple ways to accomplish this.

  1. use npm config to set the registry globally:

    npm config set registry http://nexus.dsv.myhost/nexus/repository/npmjs
    
  2. use npm config to set the registry for the package scope:

    npm config set @<your scope here>:registry http://nexus.dsv.myhost/nexus/repository/npmjs
    
  3. configure your package.json with a publish config:

    {
      ...
      "publishConfig": {
        "registry": "http://nexus.dsv.myhost/nexus/repository/npmjs"
      },
      ...
    }
    
    
  4. use npmrc to configure the registry

    registry=http://nexus.dsv.myhost/nexus/repository/npmjs
    
like image 181
Jake Holzinger Avatar answered Oct 20 '22 09:10

Jake Holzinger