我有以下 package.json 文件,我正在尝试运行 npm install,但它失败了。
"test": "git+https://<TOKEN>@github.build.test.com/test.git",
我有与 github 匹配的 ssh key 。但是,即使我写了以下内容,它也始终使用 https 运行。
"test": "git+ssh://git@github.build.test.com/test.git",
在这两种情况下,我都会遇到以下错误消息
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
如果我单独运行上面的命令,它会起作用。
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
我该如何解决?
谢谢
最佳答案
首先如果你有 url.<base>.insteadOf
directive在你的 git 配置中:
cd /path/to/repo
git config -l|grep -i insteadOf
如果没有,请设置您自己的一个:
git config url."ssh://git@github.build.test.com".insteadOf https://github.build.test.com
再看看是不是还在用https
关于git - 由于 ssh 和 https 连接的私有(private) git 存储库,npm 安装失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54016867/