Search code examples
javascriptnode.jsnpmnexus

Unable to publish private npm package to private Nexus


I have a private library and want to publish the npm packge to a private Nexus registry

My package.json configuration

{
    "name": "@organization/the-repo",
    "version": "14.2.0",
    "main": "build/lib/index.js",
    "types": "build/lib/index.d.ts",
    "private": false,
    "repository": {
        "type": "git",
        "url": "git://github.com/organization/the-repo.git"
    },
    "publishConfig": {
        "registry": "https://internal.company.com/nexus/content/repositories/npm-private/"
    }
}

My .npmrc configuration

registry=https://internal.company.com/nexus/content/groups/npm/
_auth=mYtOkEn=
always-auth=true
save-exact=true

Running

npm publish

fails because I should login first. But I have no user account, it should use the _auth from the .npmrc file.

Does someone know what's wrong or missing?


Solution

  • I had the same problem with Nexus. I had to scope the authentication to the private registry. Please try

    ( don't forget to replace <username>, <password> and the email address )

    registry=https://internal.company.com/nexus/content/groups/npm/
    //internal.company.com/nexus/content/groups/npm/:username=<username>
    //internal.company.com/nexus/content/groups/npm/:_password=<password>
    @organization:registry=https://internal.company.com/nexus/content/repositories/npm-private/
    //internal.company.com/nexus/content/repositories/npm-private/:username=<username>
    //internal.company.com/nexus/content/repositories/npm-private/:_password=<password>
    [email protected]