npm token gives E401 since 6.6.0

help-wanted
cli
triaged
priority:medium
good-first-patch

(Lars Willighagen) #1

What I Wanted to Do

Run npm token create and/or npm token list with npm 6.6.0 or newer.

What Happened Instead

I got an E401 telling me to log in on create and list, even after just logging in. Adding --otp doesn’t help.

$ npm token list
npm ERR! code E401
npm ERR! Unable to authenticate, your authentication token seems to be invalid.
npm ERR! To correct this please trying logging in again with:
npm ERR!     npm login

npm ERR! A complete log of this run can be found in:
npm ERR!     /[...]/.npm/_logs/2019-02-01T16_28_21_367Z-debug.log

$ npm login
Logged in as larsgw on https://registry.npmjs.org/.

$ npm token list
npm ERR! code E401
npm ERR! Unable to authenticate, your authentication token seems to be invalid.
npm ERR! To correct this please trying logging in again with:
npm ERR!     npm login

npm ERR! A complete log of this run can be found in:
npm ERR!     /[...]/.npm/_logs/2019-02-01T16_28_56_821Z-debug.log

Reproduction Steps

Not sure if other people have this.

$ npm login
$ npm token list

Details

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'token', 'list' ]
2 info using npm@6.7.0
3 info using node@v10.14.2
4 verbose config Skipping project config: /home/larsgw/.npmrc. (matches userconfig)
5 info token getting list
6 verbose stack Error: Unable to authenticate, need: Basic, Bearer
6 verbose stack     at res.buffer.catch.then.body (/usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:94:17)
6 verbose stack     at process._tickCallback (internal/process/next_tick.js:68:7)
7 verbose statusCode 401
8 verbose cwd [...]
9 verbose Linux 4.18.0-3-amd64
10 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "token" "list"
11 verbose node v10.14.2
12 verbose npm  v6.7.0
13 error code E401
14 error Unable to authenticate, your authentication token seems to be invalid.
15 error To correct this please trying logging in again with:
15 error     npm login
16 verbose exit [ 1, true ]

Platform Info

As mentioned, npx npm@6.5.0 token list works, even without OTP.

$ npm --versions
{ '131': '1.0.0',
  npm: '6.7.0',
  ares: '1.15.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.34.0',
  node: '10.14.2',
  openssl: '1.1.0j',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.2',
  v8: '6.8.275.32-node.45',
  zlib: '1.2.11' }
$ node -p process.platform
linux

(Lars Willighagen) #3

Seems to be fixed:


(Kat Marchán) #4

This was actually fixed by https://github.com/npm/cli/pull/149, which is already part of 6.8.0.


(Lars Willighagen) #5

Okay :slightly_smiling_face:, I just checked npmc and that worked.