npm令牌列表给出错误

时间:2018-03-28 16:39:06

标签: node.js npm

我刚刚使用:

升级了npm

npm install npm@latest -g

当我现在npm token list时,我收到以下错误:

  

npm ERR!代码EAUTHIP

     

npm ERR!无法进行身份验证,需要:基本,持票人

     

npm ERR!可以在以下位置找到此运行的完整日志:

     

npm ERR! /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中正确验证和添加令牌需要做些什么。

3 个答案:

答案 0 :(得分:4)

我可能走错了方向。我使用

登录cli
npm login

之后,我可以轻松地执行npm token list和其他相关命令,没有任何问题。

答案 1 :(得分:2)

我遇到了同样的问题,但是直到我删除当前目录中的.npmrc文件后,问题才得以解决。

即使在成功npm login之后尝试吸引用户时,我也得到了:

$ npm whoami --verbode
npm ERR! code E401
npm verb stack Error: Registry returned 401 for GET on http://registry.npmjs.org/-/whoami

更多信息,请访问: https://github.com/npm/npm/issues/16448

答案 2 :(得分:0)

如果在角度项目中出现此错误,并且如果您正在使用TFS,则=>  转到tfs =>构建=>程序包=>选择npm =>单击生成身份验证令牌按钮=>复制生成的文本=>粘贴到本地.npmrc文件中。

enter image description here

相关问题