Np: Login to private registry fails

Created on 28 May 2019  ·  5Comments  ·  Source: sindresorhus/np

Description

np fails to publish package due to login error:

? This scoped repo @scope/pkg hasn't been published. Do you want to publish it publicly? Yes

  ❯ Prerequisite check
    ↓ Ping npm registry [skipped]
    ✔ Check npm version
    ✔ Check yarn version
    ✖ Verify user is authenticated
      → You must be logged in. Use `npm login` and try again.

Yet I did login beforehand and both npm publish and yarn publish succeeded without any hitch. np also fails to ensure that my repo has been published because it has been more than once.

Steps to reproduce

I'm trying to publish a scoped package to Gemfury.io.

Expected behavior

np should use credentials npm and yarn use to login to my custom registry.

Environment

Node.js - 10.15.3 (via n)
npm - 6.9.0
yarn - 1.16.0
Git - 2.21.0
OS - OSX 10.14.4

Most helpful comment

Same issue here. We use Nexus Repository for internal packages which is a bit selective about features they implement from npm's API, so request to /collaborators fails with Bad Request error.

One very terrible hack is to bypass authentication by setting env variable NODE_ENV=test: NODE_ENV=test np.

Perhaps there could be an env variable or CLI/config option to skip authentication.

All 5 comments

I'm having the same problem. In package.json I have the following config:

  "np": {
    "contents": "lib"
  },

Actually @kapooostin I found a solution based on #256. yarn login didn't work as suggested in the thread, but using npm run release instead of yarn release did the trick.

(in my package.json I have a release script: ./node_modules/.bin/np --yolo)

I guess, this is the reason behind the issue https://github.com/sindresorhus/npm-name/issues/31

It also doesn't work for me. Even with --yolo. I have a private repo without where i don't need to login (internal network).

package.json has:

"publishConfig": {
    "registry": "http://myinternalhost:8083/repository/npm/"
},

.npmrc has:

@myscope:registry=http://myinternalhost:8083/repository/npm/

Result:

    ✖ Verify user is authenticated
      → You must be logged in. Use `npm login` and try again.

Any ideas?

Same issue here. We use Nexus Repository for internal packages which is a bit selective about features they implement from npm's API, so request to /collaborators fails with Bad Request error.

One very terrible hack is to bypass authentication by setting env variable NODE_ENV=test: NODE_ENV=test np.

Perhaps there could be an env variable or CLI/config option to skip authentication.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jescalan picture jescalan  ·  3Comments

mikehardy picture mikehardy  ·  6Comments

sindresorhus picture sindresorhus  ·  4Comments

gillesdemey picture gillesdemey  ·  3Comments

xxczaki picture xxczaki  ·  6Comments