简体   繁体   English

Gitlab 错误消息:远程:HTTP 基本:访问被拒绝致命:运行 npm 安装时身份验证失败

[英]Gitlab error message: remote: HTTP Basic: Access denied fatal: Authentication failed when running npm install on docker-compose build

I got an error message when running sudo docker-compose build运行sudo docker-compose build时收到错误消息

inside my Dockerfile, it was running:在我的 Dockerfile 里面,它正在运行:

RUN npm install

The error message says:错误消息说:

npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t https://git.mycompany.com/path_public/speakeasy.git
npm ERR! 
npm ERR! remote: HTTP Basic: Access denied
npm ERR! fatal: Authentication failed for 'https://git.mycompany.com/path_public/speakeasy.git/'
npm ERR! 
npm ERR! exited with error code: 128

I don't understand why running npm install requires git credentials.我不明白为什么运行npm install需要 git 凭据。

I have tried to copy my local git credential to the docker container with docker cp but it doesn't work.我尝试使用docker cp将我的本地 git 凭据复制到 docker 容器,但它不起作用。

This error occurs because you are trying to install a library from your private registry but you have not logged in.发生此错误是因为您尝试从私有注册表安装库但尚未登录。

1. let your git repo remember your login: (15 mins) 1. 让您的 git repo 记住您的登录: (15 分钟)

run git config --global credential.helper cache运行git config --global credential.helper cache

2. copy and paste the command it shows above, in your case: 2.复制并粘贴上面显示的命令,在您的情况下:

/usr/bin/git ls-remote -h -t https://git.mycompany.com/path_public/speakeasy.git

This will ask you for credentials.这将要求您提供凭据。 If you are using 2-factor-authentication, you have to put in your username and accesstoken , otherwise put in your password .如果您使用 2-factor-authentication,则必须输入您的usernameaccesstoken ,否则输入您的password

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

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