Bower无法通过代理获取包,git工作正常

时间:2015-01-09 08:20:47

标签: git proxy bower

我尝试使用bower来安装JQuery和其他一些库。不幸的是,它没有明显的原因(至少没有明显的理由让我失败: - )

我做了以下(在Windows命令行上):

>bower install jquery
bower jquery#*              not-cached https://github.com/jquery/jquery.git#*
bower jquery#*                 resolve https://github.com/jquery/jquery.git#*
bower jquery#*                 ECMDERR Failed to execute "git ls-remote --tags --heads https://github.com/jquery/jquery.git", exit code of #128

奇怪的是,如果我手动启动提到的git命令它可以正常工作:

>git ls-remote --tags --heads https://github.com/jquery/jquery.git
bfac0c70b1f7271934a4e081583c2b905ca1d326        refs/heads/1.11-stable
e3a802cbf7d66d88e3659ad344bce86b99d029be        refs/heads/1.9-stable
73c1ceaf4280bd0318679c1ad832181f3f449814        refs/heads/1.x-master
...

我坐在代理后面,显然在git中配置正确(之前我使用过git)。我将代理配置添加到.bowerrc但我不确定它是否正常工作。这可能是问题吗?

我感谢你的每一次帮助!

谢谢!

2 个答案:

答案 0 :(得分:2)

.bowerrc文件中添加以下行

{
    "directory": "client/bower_components",
    "proxy" : "proxy_address",
    "https-proxy" : "proxy_address",
}

并运行以下命令

git config --global url."https://".insteadOf git://

答案 1 :(得分:0)

我想我解决了它:我使用了另一个有效的代理。这很奇怪,因为之前使用的代理在所有其他应用程序中都运行良好。此外,我将Altius的答案标记为已批准,因为这基本上是我为解决它而采取的措施。

谢谢!

编辑:此外,您需要在Windows中将HTTP_PROXY和HTTPS_PROXY指定为环境变量!使用set在命令行中检查它是否正确。