react-native: react-native init hangs without any error output

After I do react-native init AwesomeProject,it just hangs at This will walk you through creating a new React Native project in /Users/jarnanchen/repo/AwesomeProject, with the slash spinning around for more than 20 minutes. Tried several times and the results are the same.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 69 (4 by maintainers)

Most upvoted comments

if you from China, do this:

npm install -g nrm
nrm use taobao

Registry has beensetto: http://registry.npm.taobao.org/

npm install -g react-native-cli --verbose
react-native init AwesomeProject --verbose

very very very … very fast

In China, npm is blocked by gfw causing react-native init hangs.

There are two solutions:

  1. modify the react-native script
    • vim which react-native``
    • exec(‘npm install --save react-native’
    • var proc = spawn(‘npm’, [‘install’, ‘–verbose’, ‘–save’, ‘react-native’], {stdio: ‘inherit’});
      • var proc = spawn(‘npm’, [‘–registry=https://registry.npm.taobao.org’, ‘install’, ‘–verbose’, ‘–save’, ‘react-native’], {stdio: ‘inherit’});
  2. add a new file .npmrc in your home dir
    • echo 'registry = https://registry.npm.taobao.org' > ~/.npmrc (Recommeded!)

Then you can re-run react-native init AwesomeProject, it would be much faster. But if you still feel it is slow, try react-native init AwesomeProject --verbose, and you can see what is going on.

I was having issue with the command react-native run-ios

Got it running by just using the sudo with the command. 😃 👍

I had react-native hang for a different reason => watchman . On my Mac, I had to:

rm -rf /usr/local/run/watchman/*

to clear whatever watchman had leftover, that was making it hang w/o any output. And along with it, it got react-native to hang:

https://github.com/facebook/react-native/blob/9ee815f6b52e0c2417c04e5a05e1e31df26daed2/packager/react-packager/src/node-haste/FileWatcher/index.js#L20

Maybe this helps anyone. It took me almost one hour to debug this …

probably related: #2797

Hanging after npm info ok seems to be caused by watchman. Just chiming in here to report the workaround documented in #9943 works.

When I run the init command, it will hangs after the output below when without sudo.

npm WARN react-native@0.27.0-rc2 requires a peer of react@15.1.0 but none was installed.
npm verb exit [ 0, true ]
npm info ok

But when I run with sudo,it will be successed,don’t konw why. The next output is:

Setting up new React Native app in /Users/ZxBing0066/Workspace/personal/App

Try running it with sudo because the long error log had “[Username] does not have permission…”. It worked in a flash for me.

@deepflame you can try npm3, it will gives you more information

Finally, I got the problem, it will takes you more than one day (connection is slow or you are in China) to clone the whole react repository.

UPDATE : After wait for a long time , the init was successful

The same problem, so I update my npm to version 3, the same problem

~/Codes/test/node_modules/react-native   242s
❯ cpm install
loadDep:react-tools → aft ▄ ╢█████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟

in package.json react-tools point to react(don’t know why)

 "react-tools": "git://github.com/facebook/react.git#b4e74e38e43ac53af8acd62c78c9213be0194245",

and I don’t know what is aft, it is not a npm package