npm在多域git存储库上安装失败

我们有一个新的项目,我们把它放在我们自己的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上拉现有的项目时失败了。 这是说无效的用户名或密码….身份validation失败。 我认为它仍然使用scott@myacme.com而不是scott@yahoo.com

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

什么是这个解决方法? 我已经尝试使用我的雅虎电子邮件地址设置gitconfiguration全局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/' 

user.name不用于使用https进行身份validation,仅在进行提交时使用(对于作者/提交者名称)

你可以做的是:

  • 对于这个GitHub仓库,使用ssh而不是https(不需要改变任何东西)。
    请参阅“ 如何让git默认为ssh,而不是https为新的存储库 ”

     git config --global url.ssh://git@github.com/.insteadOf https://github.com/ 
  • 注册您的公共ssh密钥在该GitHub回购(或至less在您的GitHub帐户 )

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