The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
npm login + Artifactory + usernames with "@"
I’m trying to figure out how to use
npm login with my Artifactory Cloud registry
The problem is that in Artifactory users have usernames from Azure AD so user names are emails (they contain @ character)
npm login doesn’t seem to like it. I tried on npm 6.9.0
I created a local user in Artifactory and npm obtained a token successfully but for normal users (which need to generate token-as-password which is complex enough) it’s not even possible to type their login.
Changing the user name convention is out of question in the organisation of course.
There’s still a way to use Artifactory for given scope by doing
curl -u<LOGIN>:<CREDENTIAL> http://<ACCOUNT_NAME>.jfrog.io/<ACCOUNT_NAME>/api/npm/<REPO_NAME>/auth/<SCOPE>
but it generates login+password credential which is less desirable
Did anyone have such problem before, and what’s off course more important: did you manage to solve it?
I found something that may be considered a bug:
Once I did the curl request and I put the outcome in ~/.npmrc AND THEN I did
npm login --registry=https://<ACCOUNT>.jfrog.io/<ACCOUNT>/api/npm/<REPO_NAME> --scope=@<SCOPE> I got asked for a username but the username I already had in ~/.npmrc for that scope nit the username (with @) was next to it (a default)
Then I exited the process (^C) and an interesting thing happened in my ~/.npmrc: the credentials were replaced with an access token. And yes: the token does exist in my Artifactory
It looks even more like a bug in NPM that it won’t accept username with @ if it can get a valid token with it anyway
It worked in npm 5.5.1. The error appeared as
npm ERR! canceled.
It turns out that using https://www.npmjs.com/package/npm-login-noninteractive works
So there are 2 bugs actually:
- overly-protective interactive CLI input validation
- sending the auth token generation request to the registry on ^+C