无法安装Bower包

5
我是一名有用的助手,可以为您进行文本翻译。以下是您需要翻译的内容:

我有一个使用 Visual Studio 2015 IDE 开发的 Cordova 应用程序。为了管理库和依赖项,我尝试使用 NuGet。但似乎 NuGet 无法管理客户端脚本,即 CSS。因此我探索了 BOWER。我使用命令 npm installl -g bower 安装了 bower,现在我可以访问所有 Bower 命令。

当我尝试添加依赖项,如 jQuery 和 jQuery Mobile 时,它会尝试获取并失败。它给出的错误是:

PATH=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\git
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\Bower.cmd" install --force-latest
bower                            retry Request to https://bower.herokuapp.com/packages/jquery-mobile failed with ECONNRESET, retrying in 1.5s
bower                            retry Request to https://bower.herokuapp.com/packages/jQuery failed with ECONNRESET, retrying in 1.4s
bower                            retry Request to https://bower.herokuapp.com/packages/jQuery failed with ECONNRESET, retrying in 3.0s
bower                            retry Request to https://bower.herokuapp.com/packages/jquery-mobile failed with ECONNRESET, retrying in 3.1s
bower                            retry Request to https://bower.herokuapp.com/packages/jQuery failed with ECONNRESET, retrying in 4.8s
bower                            retry Request to https://bower.herokuapp.com/packages/jquery-mobile failed with ECONNRESET, retrying in 7.0s
bower                            retry Request to https://bower.herokuapp.com/packages/jQuery failed with ECONNRESET, retrying in 9.7s
bower                            retry Request to https://bower.herokuapp.com/packages/jquery-mobile failed with ECONNRESET, retrying in 8.5s
bower                            retry Request to https://bower.herokuapp.com/packages/jQuery failed with ECONNRESET, retrying in 26.5s
bower                            retry Request to https://bower.herokuapp.com/packages/jquery-mobile failed with ECONNRESET, retrying in 25.6s
bower jQuery#*              ECONNRESET Request to https://bower.herokuapp.com/packages/jQuery failed: tunneling socket could not be established, cause=connect ETIMEDOUT
====Executing command 'npm install'====


npm WARN package.json WellnessAdvisor@1.0.0 No description
npm WARN package.json WellnessAdvisor@1.0.0 No repository field.
npm WARN package.json WellnessAdvisor@1.0.0 No README data

====npm command completed with exit code 0====

我浏览了一下,发现需要设置代理,具体操作如下:

http_proxy = http://<user>:<password>@<your company proxy>:<port>
https_proxy= http://<user>:<password>@<your company proxy>:<port>

或者创建一个名为.bowerrc的文件,并将代码放在其中以解决代理问题。
{
  "directory": "library",
  "registry": "http://bower.herokuapp.com",
  "proxy":"http://<USERNAME>:<PASSWORD>@<PROXY_IP>:<PROXY_PORT>/",
  "https-proxy":"http://<USERNAME>:<PASSWORD>@<PROXY_IP>:<PROXY_PORT>/"
}

但是什么都没用。现在我尝试了没有代理的开放网络,却仍然遇到同样的错误。我错过了什么基础步骤吗? 我还尝试从命令提示窗口运行,但是出现了相同的错误。

您是否能够通过浏览器访问 https://bower.herokuapp.com/packages? - Shuping
是的,我可以从浏览器访问相同的内容。URL为https://bower.herokuapp.com/packages/jQuery 给了我一个回应 {"name":"jQuery","url":"git://github.com/jquery/jquery.git","hits":47370} - Joseph
尝试重新安装 NodeJs、Cordova 和 Bower。但是还是不行。请问有人能分享一下他们的想法来帮助我解决这个问题吗?已经试验了很多线程和博客,但是没有运气。 - Joseph
1
一些问题以确定问题所在:1.) 您是否在公司代理后面,可能会阻止您尝试没有代理的开放网络?2.) 您是否尝试使用git-for-windows提供的git bash?3.) 您是否尝试使用bower cache clean清除您的bower缓存,并重新运行bower install?4.) 您能否通过命令行中的wgetcurl访问bower url? - Leon Adler
我使用随 git-for-windows 附带的 git bash,这是由 Leon Adler 建议的,对我很有效。 - Brent
2个回答

2

感谢您的支持。我已经找到了原因。虽然我没有使用公司代理,但环境变量中设置了一个属性。这意味着即使我在开放网络下,也存在代理。不知道是哪个软件在环境变量中添加了该条目。我将其删除,现在它可以正常工作。


1
这个变量叫什么?你刚刚删除了它吗?还是其他原因导致的?因为我也遇到了同样的问题。 - Oleksandr Fentsyk

1

您是否已尝试通过执行以下操作将git协议从https更改为git:

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接