2
votes

I followed the tutorial posted by facebook. Getting startted https://facebook.github.io/react-native/docs/getting-started.html#content

however, when I run react-native init AwesomeProject, I only get the following errors. My node.js is v4.1.0, npm is v2.14.3.

I don't know if my environment is ok or it just can not connect to 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: unable to connect to 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=Operation timed out

npm ERR! Darwin 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! code 128

npm ERR! Command failed: 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! Cloning into bare repository '/Users/jansenli/.npm/_git-remotes/git-github-com-facebook-react-git-baa2986b'...

npm ERR! fatal: unable to connect to github.com:

npm ERR! github.com[0: 192.30.252.129]: errno=Operation timed out

npm ERR!

npm ERR!

npm ERR!

npm ERR! If you need help, you may report this error at:

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

npm ERR! Please include the following file with any support request:

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

npm install --save react-native failed

1

1 Answers

1
votes

First - check if you can actually see github website at all. Just go to https://github.com/facebook/react and you should see the react project. If you can see, that's already good :).

The error messages indicate however that you have problem with downloading the repo via git://github.com/facebook/:react.git. You can validate that by running:

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

It should hang and you should get timeout as well.

If you cannot connect with git:// and if at the same time you can connect to github via https - my wild guess is that you have firewall blocking git protocol via port 9418 connections to github (more about the git protocol here: https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols#The-Git-Protocol). You get timeout, which is pretty standard behaviour if you are behind company firewall.

If that's the case, then there are few options. First - bypass the firewall - like do it from home or something ... If you cannot do it however, then you can try to let git always use https:// instead of git://. Apparently those two commands will configure git in this way (I have not tried it, but it should work):

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

Likely only the first command should be enough (but I am not 100% sure if it is).