【问题标题】:npm ERR! Unable to authenticate, need: Basic realm="https://pkgsprodsu3weu.app.pkgs.visualstudio.com/"npm 错误!无法认证,需要:Basic realm=\"https://pkgsprodsu3weu.app.pkgs.visualstudio.com/\"
【发布时间】:2022-08-20 18:07:12
【问题描述】:

我跑了 npm i @wtw/canvas 并得到这个错误:

npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm=\"https://pkgsprodsu3weu.app.pkgs.visualstudio.com/\"

我的 .npmrc:

@willistowerswatson:registry=https://rcss-willistowerswatson.pkgs.visualstudio.com/_packaging/Core@Local/npm/registry/
registry=https://registry.npmjs.org/
//always-auth=true
//pkgs.dev.azure.com/rcss-willistowerswatson/RadarEnterprise/_packaging/RadarEnterprise/npm/registry/:username=VssSessionToken

我已经尝试过:

vsts-npm-auth -config C:\\Users\\wilso224\\.npmrc

vsts-npm-auth v0.41.0.0
-----------------------
Already have credentials for https://rcss-willistowerswatson.pkgs.visualstudio.com/_packaging/Core@Local/npm/registry/

这也失败了:

npm i --registry https://registry.npmjs.org @wtw/canvas

结果:

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@wtw%2fcanvas - Not found
npm ERR! 404
npm ERR! 404  \'@wtw/canvas@0.1.1\' is not in the npm registry.

我已经阅读了以下内容:

npm ERR! Unable to authenticate, need: Basic realm=\"Artifactory Realm\"

npm token list giving error

https://docs.microsoft.com/en-gb/azure/devops/artifacts/npm/npmrc?view=azure-devops&tabs=windows%2Cclassic#set-up-authentication-on-your-dev-box

https://developercommunity.visualstudio.com/t/401-when-attempting-to-run-npm-install/928369

谢谢。

编辑#1 无论如何,我尝试了 npm login,它要求我设置一个新帐户等。我从事这项工作已经 3 年多,我不记得每次遇到此类错误时都需要设置一个帐户。

  • 你试过npm login
  • 我得到了 npm 错误! 404 未找到 - 获取 registry.npmjs.org/@wtw%2fcanvas - 未找到
  • 你需要重置你的 npm 配置,最简单的方法是重新安装 nodejs(使用 nvm 应该超级容易)
  • 我必须使用与团队其他成员相同的 nodejs 版本——nvm 会让我选择不同的版本
  • 这个问题是与 Realm 直接相关还是只是一个 npm install/config 问题?

标签: node.js npm realm


【解决方案1】:

第一次运行:

vsts-npm-auth -config .npmrc -force

接着:

npm i

【讨论】:

    【解决方案2】:

    如果强制re-auth不起作用,您可能需要清理并重新安装vsts-npm-auth

    这些步骤对我有用:

    1. 卸载 vsts-npm-auth
      npm uninstall -g vsts-npm-auth
      
      1. 清理 npm 缓存
      npm cache clean --force
      
      1. 删除.npmrc 文件

      2. 重新安装

      npm install -g vsts-npm-auth --registry https://registry.npmjs.com --always-auth false
      

      微软文档:
      https://docs.microsoft.com/en-us/azure/devops/artifacts/npm/npmrc?view=azure-devops&tabs=windows%2Cclassic#reset-vsts-npm-auth

    【讨论】:

      猜你喜欢
      • 2021-10-14
      • 2022-08-11
      • 2020-08-20
      • 1970-01-01
      • 2021-11-02
      • 2018-09-28
      • 2020-05-10
      • 2017-07-11
      • 2017-12-25
      相关资源
      最近更新 更多