为专用注册表安装时出现npm安装未经授权的错误



我正在尝试安装一个项目,但在该项目的一个依赖项上收到了一个npm 128错误代码。

npm install
npm ERR! Error while executing:
npm ERR! C:Program FilesGitmingw64bingit.EXE ls-remote -h -t git@gitlab.mysite.com:myprivaterepo
npm ERR!
npm ERR! Permission denied, please try again.
npm ERR! Permission denied, please try again.
npm ERR! git@gitlab.mysite.com: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128
npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersuserAppDataRoamingnpm-cache_logs2020-07-13T12_19_31_285Z-debug.log

我通常使用gitBash和在后台运行的代理进行ssh连接,我可以直接从gitLab repo中克隆增加的依赖项,但我不能从npm安装的主项目中克隆。我还试图执行引发错误的命令,它起作用了:

git ls-remote --tags --heads git@gitlab.mysite.com:myprivaterepo
0099c1913ecc392394413554c5b22f2ea0b22b43        refs/heads/feature/generate-manifests
b67ca49f1d6ec9cf77ddd233a4f7b25d7a977d75        refs/heads/master
8787a2dafbfebef21a9cf77c8081b745979e76fe        refs/heads/refactor/use-docker-compose-pull
70ee2ca3e44b6dedb4d4cf3984cec20dcf3283be        refs/tags/1.0.0
9260ee68b9fd4972f18a51dc7c21d2a8559bc51e        refs/tags/1.0.0^{}
fa44564e49035b5c1eecaeb9092332e60b5dfa0a        refs/tags/1.0.1
0c3ef1ec8621614c83668841a69769c496d74ee4        refs/tags/1.0.1^{}
86a351644be3994f0bcd8b4cdbd2b9721d296440        refs/tags/1.0.2
f5c24db1d09cc3d35aa35816b8ad5528c60b6d79        refs/tags/1.0.2^{}
cc0b8bf529390eb9c1137aeeee82925b3f37c985        refs/tags/1.0.3
3002e6cce768eff4bdb6872b7856763065e0f545        refs/tags/1.0.3^{}
37fbaa00a3ffe116113af98243bb5abffd4e7d3a        refs/tags/1.0.4
fac2008469dd9c1bb20b5a3d811586ee04527664        refs/tags/1.0.4^{}
d209098860a9f6f6b562431a065500bff2b2702f        refs/tags/1.0.5
b67ca49f1d6ec9cf77ddd233a4f7b25d7a977d75        refs/tags/1.0.5^{}

我也试过用纱线,我也有同样的问题。还尝试了从最新到8.0.0的不同节点版本,或者从头开始删除并重新安装节点和npm。

这是我的包.json:

{
"name": "my-project",
"version": "1.0.0",
"description": "",
"main": "app/index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"repository": {
"type": "git",
"url": "ssh://git@gitlab.mysite.com/myproject/myfolder"
},
"keywords": [
"my-keyword"
],
"author": "my@email.com",
"license": "mylicense",
"dependencies": {
"my-dependency": "git+ssh://git@gitlab.mysite.ch:my-repo/my-folder/my-repo",
"lodash": "^3.10.1",
"xml2js": "0.4.17"
}
}

有人暗示出了什么问题?

嗨,Francesco,欢迎来到SO!

我认为问题是npm执行的git进程超出了你的git Bash的范围,它是一个MinGW。看起来npm在纯windows上下文中执行git.exe,因此它对您的MinGW环境一无所知。我建议您将ssh密钥放在Git Bash中的~/.ssh和windows中的%USERPROFILE%.ssh中。或者在MinGW侧创建符号链接。

相关内容

最新更新