简体   繁体   English

npm 安装私有注册表时安装未授权错误

[英]npm install unauthorized error on install for private registry

I am trying to install a project and I get a npm 128 error code on one dependency of the project.我正在尝试安装一个项目,但在项目的一个依赖项上出现 npm 128 错误代码。

npm install
npm ERR! Error while executing:
npm ERR! C:\Program Files\Git\mingw64\bin\git.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:\Users\user\AppData\Roaming\npm-cache\_logs\2020-07-13T12_19_31_285Z-debug.log

I am normally using gitBash with agent running in background for ssh connections and I can directly clone from the gitLab repo of the incriminated dependency but i can't from the main project with npm install.我通常使用 gitBash 和代理在后台运行 ssh 连接,我可以直接从 gitLab 存储库中克隆依赖项,但我不能使用 ZBB30E85411B445DF41296726 从主项目中克隆。 I also tried to execute the command that is throwing the error and it works:我还尝试执行引发错误的命令并且它有效:

 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^{}

Tried also with yarn and I have the same problem.也试过纱线,我也有同样的问题。 Tried also different node versions from the latest to the 8.0.0 or deleting and re-installing from scratch node and npm.还尝试了从最新到 8.0.0 的不同节点版本,或者从头开始删除并重新安装节点和 npm。

This is my package.json:这是我的 package.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"
  }
}

Someone has any hint on what's the problem?有人对有什么问题有任何提示吗?

Hi Francesco and welcome to SO!嗨弗朗西斯科,欢迎来到 SO!

I think the problem is that the git process executed by npm runs out of the scope of your Git Bash, which is a MinGW. I think the problem is that the git process executed by npm runs out of the scope of your Git Bash, which is a MinGW. It looks like npm executes git.exe in pure windows context, hence it doesn't know anything about your MinGW environment.看起来git.exe在纯 windows 上下文中执行 git.exe,因此它对您的 MinGW 环境一无所知。 I would suggest you to place your ssh-keys both in ~/.ssh in Git Bash and in %USERPROFILE%\.ssh in windows. I would suggest you to place your ssh-keys both in ~/.ssh in Git Bash and in %USERPROFILE%\.ssh in windows. Or to create symbolic links on MinGW side.或者在 MinGW 端创建符号链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM