[英]npm install fails due to private git repository both ssh and https connections
I have the following package.json file and I am trying to run npm install, but it fails. 我有以下package.json文件,我正在尝试运行npm install,但它失败了。
"test": "git+https://<TOKEN>@github.build.test.com/test.git",
I have ssh key matched to github. 我有与github匹配的ssh密钥。 However even I write the following, it always run with https.
但是,即使我写下以下内容,它也始终使用https运行。
"test": "git+ssh://git@github.build.test.com/test.git",
In both case, I encounter following error message 在这两种情况下,我都会遇到以下错误消息
npm ERR! Error while executing:
npm ERR! C:\Program Files\Git\cmd\git.EXE ls-remote -h -t https://github.build.test.com/test.git
npm ERR!
npm ERR! remote: Password authentication is not available for Git operations.
npm ERR! remote: You must use a personal access token or SSH key.
npm ERR! remote: See https://github.build.test.com/settings/tokens or https://github.build.test.com/settings/ssh
npm ERR! fatal: unable to access 'https://github.build.test.com/test.git/': The requested URL returned error: 403
npm ERR!
npm ERR! exited with error code: 128
If I run above command separately, it works. 如果我单独运行上面的命令,它的工作原理。
git ls-remote -h -t https://<TOKEN>@github.build.test.com/test.git
git ls-remote -h -t ssh://git@github.build.test.com/test.git
How can I fix it? 我该如何解决?
Thanks 谢谢
First if you have any url.<base>.insteadOf
directive in your git configuration: 首先,如果你的git配置中有任何
url.<base>.insteadOf
指令 :
cd /path/to/repo
git config -l|grep -i insteadOf
And if not, set one of your own: 如果没有,请设置一个:
git config url."ssh://git@github.build.test.com".insteadOf https://github.build.test.com
See then if it is still using https. 如果它仍在使用https,请参阅。
If you are going to use "git+ssh://git@github.build.test.com/test.git" you should be able to clone this repository without passing credentials. 如果您打算使用“git + ssh://git@github.build.test.com/test.git”,您应该能够克隆此存储库而无需传递凭据。 Simple
git clone git+ssh://git@github.build.test.com/test.git
shouldn't ask for pass or username. 简单的
git clone git+ssh://git@github.build.test.com/test.git
不应该要求传递或用户名。
You probably need to configure your git public/private keys. 您可能需要配置您的git公钥/私钥。 Your locally used key for cloning must be added to repository config.
必须将本地使用的克隆密钥添加到存储库配置中。 For example for github is possible to configure it on https://github.com/settings/keys
例如,对于github,可以在https://github.com/settings/keys上配置它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.