[英]npm install failing on multi domain git repository
我們有一個新項目,並將其托管在我們自己的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
解決方法是什么? 我嘗試使用yahoo電子郵件地址設置git config全局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進行身份驗證,僅在進行提交時使用(用於作者/提交者名稱)
您可以做的是:
對於該GitHub存儲庫,請使用ssh而不是https(無需更改源代碼中的任何內容)。
請參閱“ 如何使git默認為ssh而不是新存儲庫的https ”
git config --global url.ssh://git@github.com/.insteadOf https://github.com/
在該GitHub存儲庫上(或至少在您的GitHub帳戶中 )注冊您的公共ssh密鑰
這樣, git clone
將在GitHub(您的GitHub scott
帳戶,因為它具有正確的ssh公鑰)上使用已知的身份驗證。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.