sindresorhus / np

A better `npm publish`

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Login to private registry fails (Verdaccio, Nexus, …)

kapooostin opened this issue · comments

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

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 sindresorhus/npm-name#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.

@fregante After looking at all those issues, what would you suggest to fix the problem? Seems like a skip of the collaborators resource (and not failing) would be simple enough. PRs welcome for adding this?

Given the age of this issue I'd say support isn't a priority, but mostly the issue is #320

I don't know what the consequences of "just ignore the collaborators check" would be. It sounds like if it's there it shouldn't just be ignored.

Given the shortage of collaborators here, I suggest lobbying those vendors instead, which are paid (in the case of Nexus). Particularly for stuff like #519 (comment)

if it's there it shouldn't just be ignored

Seems like npm does just fine without it on third-party registries.