我已设置以下命令以防止npm使用GIT协议下载NPM包,因为它以某种方式被我的服务器阻止:
git config --global url."https://github.com/".insteadOf git@github.com
但是,在运行npm install
时,由于程序包在镜像的repo克隆环境中尝试使用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?
答案 0 :(得分:1)
我能够使用(git://而不是git @)
来解决这个问题git config --global url."http://github.com".insteadOf git://github.com