我正在尝试从一个私有的Bitbucket存储库安装一个NPM模块。
我可以在系统本地成功运行npm install,但在服务器上运行失败。
错误是:
npm ERR! Error while executing:
npm ERR! /bin/git ls-remote -h -t ssh://git@bitbucket.org/myorg/my-repo.git
npm ERR!
npm ERR!
npm ERR! (ssh-askpass:10260): Gtk-WARNING **: cannot open display: :0.0
npm ERR! Host key verification failed.
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奇怪的是,手动克隆服务器上的存储库效果很好:git clone git@bitbucket.org:myorg/my-repo
因此,SSH密钥配置正确。
发布于 2018-10-19 13:10:02
这应该表明执行npm命令所使用的帐户与用于在服务器上手动克隆存储库的帐户不同。
发布于 2020-08-27 03:15:21
我认为你是从Docker容器访问它,因为你没有从docker容器添加ssh密钥,这是存在问题的。因此,有两种解决方案
推荐的做法
docker文件中的更改将是
INITIALLY :
FROM node:12.10-alpine
WORKDIR /app
RUN apk update \
&& apk add git
COPY node_modules /app
COPY . /app
ADD set_envs.sh .
RUN ["chmod", "+x", "set_envs.sh"]
EXPOSE 80
ENTRYPOINT ["/app/set_envs.sh"]
AFTER CHANGES :
FROM node:12.10-alpine
WORKDIR /app
COPY node_modules /app
COPY . /app
ADD set_envs.sh .
RUN ["chmod", "+x", "set_envs.sh"]
EXPOSE 80
ENTRYPOINT ["/app/set_envs.sh"]和在配置添加的Jenkins的shell脚本中
npm install就是这样,它应该可以工作
https://stackoverflow.com/questions/52883884
复制相似问题