3

I am trying to use npm.pkg.github.com to host a NPM package.

I followed this guide https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry

When I try to run npm login ... (see bellow) I got the error "401 Unauthorized".

My password is correct, I checked more than four times.

npm login --scope=@mycompany --registry=https://npm.pkg.github.com
Username: myuser
Password: 
Email: (this IS public) myemail@gmail.com
npm ERR! code E401
npm ERR! 401 Unauthorized - PUT https://npm.pkg.github.com/-/user/org.couchdb.user:myuser - Error authenticating user: Requires authentication

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ubuntu/.npm/_logs/2021-09-23T13_35_53_341Z-debug.log

Here the logs

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/home/ubuntu/.nvm/versions/node/v14.17.6/bin/node',
1 verbose cli   '/home/ubuntu/.nvm/versions/node/v14.17.6/bin/npm',
1 verbose cli   'login',
1 verbose cli   '--scope=@mycompany',
1 verbose cli   '--registry=https://npm.pkg.github.com'
1 verbose cli ]
2 info using npm@6.14.15
3 info using node@v14.17.6
4 verbose npm-session 31a7580c954cdd70
5 verbose web login before first POST
6 http fetch POST 404 https://npm.pkg.github.com/-/v1/login 308ms
7 verbose web login not supported, trying couch
8 verbose login before first PUT {
8 verbose login   _id: 'org.couchdb.user:myuser',
8 verbose login   name: 'myuser',
8 verbose login   password: 'XXXXX',
8 verbose login   type: 'user',
8 verbose login   roles: [],
8 verbose login   date: '2021-09-23T13:35:52.873Z'
8 verbose login }
9 http fetch PUT 401 https://npm.pkg.github.com/-/user/org.couchdb.user:myuser 288ms
10 verbose adduser before first PUT {
10 verbose adduser   _id: 'org.couchdb.user:myuser',
10 verbose adduser   name: 'myuser',
10 verbose adduser   password: 'XXXXX',
10 verbose adduser   email: 'myemail@gmail.com',
10 verbose adduser   type: 'user',
10 verbose adduser   roles: [],
10 verbose adduser   date: '2021-09-23T13:35:53.162Z'
10 verbose adduser }
11 http fetch PUT 401 https://npm.pkg.github.com/-/user/org.couchdb.user:myuser 170ms
12 verbose stack Error: 401 Unauthorized - PUT https://npm.pkg.github.com/-/user/org.couchdb.user:myuser - Error authenticating user: Requires authentication
12 verbose stack     at /home/ubuntu/.nvm/versions/node/v14.17.6/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:117:15
12 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:95:5)
13 verbose statusCode 401
14 verbose cwd /home/ubuntu/workspace/mycompany/uikit
15 verbose Linux 5.10.16.3-microsoft-standard-WSL2
16 verbose argv "/home/ubuntu/.nvm/versions/node/v14.17.6/bin/node" "/home/ubuntu/.nvm/versions/node/v14.17.6/bin/npm" "login" "--scope=@mycompany" "--registry=https://npm.pkg.github.com"
17 verbose node v14.17.6
18 verbose npm  v6.14.15
19 error code E401
20 error 401 Unauthorized - PUT https://npm.pkg.github.com/-/user/org.couchdb.user:myuser - Error authenticating user: Requires authentication
21 verbose exit [ 1, true ]

When I ran npm whoam

npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in.
npm ERR! need auth You need to authorize this machine using `npm adduser`

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ubuntu/.npm/_logs/2021-09-23T17_13_01_791Z-debug.log

npm --version

6.14.15

Also, I have on my .npmrc this line

//npm.pkg.github.com/:_authToken=SECRET_TOKEN

The most strange is: /user/org.couchdb.user. I am not part of couchdb org.

What I am doing wrong?

Rodrigo
  • 135
  • 4
  • 45
  • 107
  • just to be on the safe side here, (1) there is no space between npm options (e.g. `npm login --scope=@mycompany--registry=https://npm.pkg.github.com`) - did you look into it? (2) are you using environment variable named `SECRET_TOKEN` or did you only redacted the token and replaced it with the string `SECRET_TOKEN`? – Mr. Sep 23 '21 at 16:37
  • I replaced my token by SECRET_TOKEN. Also, there is a space between -- in my command, it was a typo when I pasted here – Rodrigo Sep 23 '21 at 16:48
  • what do you get when you run `npm whoami`? – Mr. Sep 23 '21 at 17:05
  • npm whoam npm ERR! code ENEEDAUTH npm ERR! need auth This command requires you to be logged in. npm ERR! need auth You need to authorize this machine using `npm adduser` npm ERR! A complete log of this run can be found in: npm ERR! /home/ubuntu/.npm/_logs/2021-09-23T17_13_01_791Z-debug.log – Rodrigo Sep 23 '21 at 17:13

0 Answers0