我设置了以下命令,以防止npm下载带有GIT协议的NPM包,因为它被我的服务器阻塞了:
git config --global url."https://github.com/".insteadOf git@github.com
但是,在运行npm install
时,仍然会发生错误,因为包试图使用Git协议,在从镜像进行回购克隆的上下文中:
npm ERR! git clone --template=/home/jenkins/.npm/_git-remotes/_templates --mirror git://github.com/isaacs/js-yaml.git /home/jenkins/.npm/_git-remotes/git-github-com-isaacs-js-yaml-git-dd3d7a8b: Cloning into bare repository '/home/jenkins/.npm/_git-remotes/git-github-com-isaacs-js-yaml-git-dd3d7a8b'...
npm ERR! git clone --template=/home/jenkins/.npm/_git-remotes/_templates --mirror git://github.com/isaacs/js-yaml.git /home/jenkins/.npm/_git-remotes/git-github-com-isaacs-js-yaml-git-dd3d7a8b:
npm ERR! git clone --template=/home/jenkins/.npm/_git-remotes/_templates --mirror git://github.com/isaacs/js-yaml.git /home/jenkins/.npm/_git-remotes/git-github-com-isaacs-js-yaml-git-dd3d7a8b: fatal: unable to connect to github.com:
npm ERR! git clone --template=/home/jenkins/.npm/_git-remotes/_templates --mirror git://github.com/isaacs/js-yaml.git /home/jenkins/.npm/_git-remotes/git-github-com-isaacs-js-yaml-git-dd3d7a8b: github.com[0: 192.30.252.129]: errno=Connection refused
我比较了安装到node_modules中的模块和在package.json中声明的模块,唯一丢失的模块是grunt-contrib-nodeunit
,奇怪的是它不依赖于js-yaml
.那么,为什么它想克隆它的回购呢?在任何情况下,在指定镜像时是否有强制使用HTTPS的方法?
发布于 2015-05-08 19:42:58
我能够使用(git://而不是git@)绕过这个问题。
git config --global url."http://github.com".insteadOf git://github.com
发布于 2022-10-11 13:27:43
我无法用Gitlab CI解决这个问题。由于某些原因,npm
不会使用我的insteadOf规则,即使日志上没有打印任何内容。
我的解决方案是直接使用sed
编辑原始文件:
sed -i -e "s/ssh\:\/\/git\@myrepo\.com\:/https\:\/\/myrepo\.com\//g" package.json
这将将所有ssh://git@myrepo.com:
替换为https://myrepo.com/
(请注意,尾随的被/替换)。
https://stackoverflow.com/questions/30126626
复制相似问题