我在从 cmd
调用以下命令安装 PhoneGap 时遇到问题:
npm install -g phonegap
返回以下错误:
Failed to connect to github.com port 443: Timed out
关于这个主题有很多问题,它们似乎都提供了相同的答案 - 确保配置了 git
和 nodejs
的代理设置。我像这样设置了 node
代理设置:
npm config set proxy http://proxyname:8080
npm config set https-proxy http://proxyname:8080
对于git
:
git config --global http.proxy http://proxyname:8080
git config --global https.proxy http://proxyname:8080
git config --list
和 npm config list
均确认这些代理设置已到位。
我还通过转到 Windows 防火墙
-> Allow a program or feature through windows firewall
允许程序通过防火墙。然后我为 Node.js
选择了 node.exe
,为 git
选择了 git.exe
。
但是我仍然遇到无法连接到 Github 的问题。还有什么我遗漏或忘记设置的吗?为此任务首次安装了 Node.js 和 Git。
最佳答案
除了上述设置之外,如果某些下载的库使用 git://
协议(protocol)而不是 https:/声明它们的依赖关系,则可能会出现此错误/
。这些依赖项通常会因上述错误而失败。
要解决此问题,您可以运行以下命令:
git config --global url."https://".insteadOf git://
这将为 Git 添加一个配置选项,要求 Git 在 URL 使用 git://
协议(protocol)时使用 https
。
此设置为我解决了许多代理问题。
关于node.js - 在企业代理 Node.js 后面访问 Github,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31113433/