【发布时间】:2018-09-07 11:00:46
【问题描述】:
我刚刚升级了 npm,使用:
npm install npm@latest -g
当我现在执行npm token list 时,出现以下错误:
npm 错误!代码 EAUTHIP
npm 错误!无法认证,需要:Basic、Bearer
npm 错误!可以在以下位置找到此运行的完整日志:
npm 错误! /Users/USerName/.npm/_logs/2018-03-28T16_31_29_299Z-debug.log
以下是上述日志文件的内容:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/6.8.1/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'token',
1 verbose cli 'list' ]
2 info using npm@5.8.0
3 info using node@v6.8.1
4 info token getting list
5 http request → GET https://registry.npmjs.org/-/npm/v1/tokens
6 http 401 ← Unauthorized (https://registry.npmjs.org/-/npm/v1/tokens)
7 verbose stack Error: Unable to authenticate, need: Basic, Bearer
7 verbose stack at fetch.defaults.catch.then.then.result (/usr/local/lib/node_modules/npm/node_modules/npm-profile/index.js:373:15)
7 verbose stack at process._tickCallback (internal/process/next_tick.js:103:7)
8 verbose statusCode 401
9 verbose cwd /Users/saurabh.mimani/work/codes/mongoose-diff-history
10 verbose Darwin 17.4.0
11 verbose argv "/usr/local/Cellar/node/6.8.1/bin/node" "/usr/local/bin/npm" "token" "list"
12 verbose node v6.8.1
13 verbose npm v5.8.0
14 error code EAUTHIP
15 error Unable to authenticate, need: Basic, Bearer
16 verbose exit [ 1, true ]
在 CLI 中正确验证和添加令牌需要做什么。
【问题讨论】: