2015-09-20 56 views
1

我跟着Facebook发布的教程。开始https://facebook.github.io/react-native/docs/getting-started.html#contentreact-native init AwesomeProject无法连接到github.com

但是,当我运行react-native init AwesomeProject时,我只会得到以下错误。我的node.js是v4.1.0,npm是v2.14.3。

我不知道我的环境是否好,或者它只是无法连接到github.com?

npm ERR! git clone --template =/Users/jansenli/.npm/_git-remotes/_templates --mirror git://github.com/facebook/react.git /Users/jansenli/.npm/_git-remotes/git-github -com-facebook-react-git-baa2986b:fatal:无法连接到github.com:

npm ERR! git clone --template =/Users/jansenli/.npm/_git-remotes/_templates --mirror git://github.com/facebook/react.git /Users/jansenli/.npm/_git-remotes/git-github -com-facebook-react-git-baa2986b:github.com [0:192.30.252.129]:errno =操作超时

npm ERR!达尔文14.5.0

npm ERR! argv“/Users/jansenli/.nvm/versions/node/v4.1.0/bin/node”“/Users/jansenli/.nvm/versions/node/v4.1.0/bin/npm”“install”“--save “”react-native“

npm ERR! node v4.1.0

npm ERR! npm v2.14.3

npm ERR!代码128

npm ERR!命令失败:git clone --template =/Users/jansenli/.npm/_git-remotes/_templates --mirror git://github.com/facebook/react.git /Users/jansenli/.npm/_git-remotes/ git-github-com-facebook-react-git-baa2986b

npm ERR!克隆到裸仓库'/Users/jansenli/.npm/_git-remotes/git-github-com-facebook-react-git-baa2986b'...

npm ERR!致命:无法连接到github.com:

npm ERR! github.com [0:192.30.252.129]:errno =操作超时

npm ERR!

npm ERR!

npm ERR!

npm ERR!如果您需要帮助,您可能会在以下位置报告此错误:

npm ERR! https://github.com/npm/npm/issues

npm ERR!请包括以下文件与任何支持请求:

npm ERR! /Users/jansenli/AwesomeProject/npm-debug.log

npm install --save react-native失败

回答

0

首先 - 检查你可以看到的github网站所有。只需转到https://github.com/facebook/react,您应该看到反应项目。如果你能看到,那已经很不错了:)。

但是,错误消息表明您有通过git:// github下载repo的问题。COM/Facebook的/:react.git。你可以通过运行验证:

git clone git://github.com/facebook/react.git 

它应该挂起,你也应该超时。

如果你无法连接到git://并且同时你可以通过https连接到github - 我的猜测是你有防火墙阻止git协议通过端口9418连接到github(更多关于git协议这里:https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols#The-Git-Protocol)。你会得到超时,如果你在公司防火墙后面,这是非常标准的行为。

如果是这样的话,那么几乎没有选择。首先 - 绕过防火墙 - 就像在家里做的那样...如果你不能做到这一点,那么你可以尝试让git总是使用https://而不是git://。显然,这两个命令会以这种方式配置的git(我还没有尝试过,但它应该工作):

git config --global url."https://github.com/".insteadOf [email protected]: 
git config --global url."https://".insteadOf git:// 

很可能只会在第一个命令应该是足够的(但我不是100%,如果确定它是) 。

相关问题