【问题标题】:npm token list giving errornpm 令牌列表给出错误
【发布时间】: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 中正确验证和添加令牌需要做什么。

【问题讨论】:

    标签: node.js npm


    【解决方案1】:

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

    登录了 cli
    npm login
    

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

    【讨论】:

    • 似乎当我在 ~/ 登录并运行 npm token list 时,一切正常。但是当我更改目录时,npm token list 失败
    【解决方案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

    【讨论】:

      【解决方案3】:

      如果 Angular 项目中出现此错误,并且如果您使用的是 TFS,则 => 转到 tfs => build=> packages=> 选择 npm => 单击生成身份验证令牌按钮 => 复制生成的文本 => 将其粘贴到本地 .npmrc 文件中。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-10-28
        • 2018-10-20
        • 2016-11-24
        • 1970-01-01
        • 2014-10-13
        • 2013-12-25
        • 2013-04-09
        • 1970-01-01
        相关资源
        最近更新 更多