如何解决 npm install 中的身份验证错误?

How to resolve authentication error in npm install?

在我的 package.json 中,我有一个名为 somerepo.git 的私人仓库。现在我 运行 通过 Maven 在 buildserver(bamboo) 上安装 npm 并收到此错误:

[ERROR] npm ERR! Command failed: git clone --template=/var/home/ci/.npm/_git-remotes/_templates --mirror https://somerepo.git
[ERROR] npm ERR! fatal: Authentication failed for https://somerepo.git

如何解决存储库的身份验证问题?

如果可以,你应该:

  • 通过 ssh 访问私人仓库
  • 使用您注册到 Git 远程托管服务器的部署或 trusted key,以允许您的 CI 服务器访问它。
  • 配置您的 .ssh/config 文件以便 npm 使用正确的密钥:请参阅“Is there a way to specify which ssh key should be used for npm install