【问题标题】:npm install failing on multi domain git repositorynpm install 在多域 git 存储库上失败
【发布时间】:2016-01-06 21:13:01
【问题描述】:

我们有一个新项目,我们将它托管在我们自己的 Gitlab 服务器中。我从

克隆了它
git@git.myacme.com:webapplication/app.git

成功了。

假设我在 gitlab 中的用户名是 scott@myacme.com。

我们在 Github 中也有一个现有项目,我使用的用户名是 scott@yahoo.com

在新项目中,我们在 package.json 中有一个指向现有项目的条目。注意 https

https://github.com/myacme/system-application.git

现在,当我执行 npm install 时,它尝试拉取 github.com 中的现有项目时失败。它说无效的用户名或密码....身份验证失败。我认为它仍在使用 scott@myacme.com 而不是 scott@yahoo.com

我不允许更改 package.json。我正在考虑将其更改为 git 链接而不是 https,但我会影响其他开发人员。如果我这样做,我认为它将使用我在 .ssh/config 中放置的设置。我添加了 2 个主机,我们的 myacme.com 和 github.com

解决方法是什么?我尝试使用我的雅虎电子邮件地址设置 git config global user.name 和 user.email 但它仍然没有使用它。我没有想法。

这是 npm-debug.log 文件中的确切错误

515 error git clone --template=/Users/scott/.npm/_git-remotes/_templates --mirror https://github.com/myacme/system-application.git /Users/scott/.npm/_git-remotes/https-github-com-myacme-system-application-git-0be15bdd: remote: Invalid username or password.

515 error git clone --template=/Users/scott/.npm/_git-remotes/_templates --mirror https://github.com/myacme/system-application.git /Users/scott/.npm/_git-remotes/https-github-com-myacme-system-application-git-0be15bdd: fatal: Authentication failed for 'https://github.com/myacme/system-application.git/'

【问题讨论】:

    标签: node.js git github npm gitlab


    【解决方案1】:

    user.name 不用于 https 的身份验证,仅在提交时使用(用于作者/提交者名称)

    你可以做的是:

    这样,git clone 将使用 GitHub 上的已知身份验证(您的 GitHub scott 帐户,因为它具有正确的 ssh 公钥)。

    【讨论】:

    • 我应该提到 git clone 工作正常。这是一个 npm 问题
    • 我决定把它改成 package.json 中的 git 链接,明天我会通知我的队友。我没时间了。我现在很好
    • @devwannabe “尝试拉取 github.com 中的现有项目时失败。”这将使它不会失败。无需更改任何网址。
    • 哇,学到了新东西!太棒了!有效! :) 谢谢!
    猜你喜欢
    • 2017-07-23
    • 2014-02-21
    • 1970-01-01
    • 1970-01-01
    • 2021-11-28
    • 2016-06-29
    • 2020-02-25
    • 2020-05-25
    • 2021-12-26
    相关资源
    最近更新 更多