np icon indicating copy to clipboard operation
np copied to clipboard

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

Open kapooostin opened this issue 5 years ago • 8 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

kapooostin avatar May 28 '19 15:05 kapooostin

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

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

brmscheiner avatar Jun 05 '19 21:06 brmscheiner

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)

brmscheiner avatar Jun 05 '19 22:06 brmscheiner

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

kapooostin avatar Jun 05 '19 22:06 kapooostin

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?

bavarianbytes avatar May 06 '20 11:05 bavarianbytes

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.

jnv avatar Jan 06 '21 12:01 jnv

@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?

slhck avatar Feb 03 '23 13:02 slhck

Given the age of this issue I'd say support isn't a priority, but mostly the issue is https://github.com/sindresorhus/np/issues/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 https://github.com/sindresorhus/np/issues/519#issuecomment-1415718431

fregante avatar Feb 03 '23 13:02 fregante

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

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

slhck avatar Feb 03 '23 13:02 slhck