React-native: Init project hangs forever

Created on 17 Sep 2015  ·  60Comments  ·  Source: facebook/react-native

I cannot create a new react-native project any more (worked yesterday). The init command hangs forever in this state:

$ react-native init MyProject
This will walk you through creating a new React Native project in /Users/.../Projects/MyProject
\

The directory MyProject gets created with a single file package.json with the following content:

{"name":"MyProject","version":"0.0.1","private":true,"scripts":{"start":"node_modules/react-native/packager/packager.sh"}}

The slash/backslash is still flipping but no matter how long I wait, nothing happens. Connection to NPM is working generally, e.g. I'm able to install new packages, so my internet connection should be fine.

I tried with Node 4.0.0 as well as latest Node 4.1.0 and NPM 2.14.3.

I'm curious because yesterday everything worked like a charm, so I guess my general config is fine.

Any help?

Locked

Most helpful comment

To everyone having problems with project creation:

With next version of React Native CLI you can use --verbose option to get a clue what's going on:

react-native init MyAwesomeProject --verbose

All 60 comments

Hm, after a couple of retries and after waiting a huge amount of time, the project is finally created.

Hi @winterbe I had the same issue , I don't know why is it taking so long to init, what's the root cause?

I really don't know what causes this issue. It took like 10 min until some logs get printed and the command succeeded. Is there some kind of -verbose mode for react-native-cli? That would be handy in those situations.

Am 17.09.2015 um 17:28 schrieb Jr [email protected]:

Hi @winterbe I had the same issue , I don't know why is it taking so long to init, what's the root cause?


Reply to this email directly or view it on GitHub.

I get the same problem. I let it run for hours and it still hadn't gone beyond the one file and the same line mentioned above by @winterbe.

I am on node v4.0.0 and npm v2.14.2.

I first thought that it was a local problem on my machine/ network but it seems more and more people have the same problem.

So I reopen the issue now in hope that someone finds out the root cause of the problem.

+1

Happening for me too.

Same problem here, I have to keep trying to get it to complete and build.
Has anyone found a solution?

It's weird, it only happened to me on a MacBook where I had made some aborted early attempts to brew install, and hadn't done the updating and symlinking right and had to fix permissions prior to running the command line tool.

On my desktop Mac, when I brew updated first, it ran much smoother (and there weren't any symlink or permissions issues)

+1

Something is definitely taking too long, but it works after 10 minutes on my late 2012 macbook pro. I was about to give up but it kept spinning.

node --version
v4.1.1

It downloads about ~73mb of data and does that very slowly, but once it is downloaded, it goes through just fine. You can use something that monitors the git process to see where it's at.

@swastik how would you monitor the git process?

Wish there were more verbose messages on what was happening.

@iSimar — On a Mac, open Activity Monitor, go to the 'Network' tab, and you'll see it there.

I am facing the same problem.

We actually decided to hide the output from npm install in https://github.com/facebook/react-native/commit/2ddf3d942dc080264bf5f17c1381e7e5f39e2f4f

Happy to review a pull request that adds the output back under a --verbose option.

+1
Location: kolkata, India

@mkonicek I'll be looking into it.

To everyone having problems with project creation:

With next version of React Native CLI you can use --verbose option to get a clue what's going on:

react-native init MyAwesomeProject --verbose

yay! :+1:

Thanks for the PR @winterbe!

My pleasure! React native is awesome, keep up the great work every one!

I'm on SEA region, facing the same issue. Verbose doesn't seem to output anything. The only thing that works for me is to not to use the cli at all, rather create a project folder with the usual npm init. What I found out is that when you run npm i react-native --verbose it will freeze at certain phase. I ran it several time the freeze seem to be random. Somehow npm try to add the modules that react-native needs into the cache but somehow freeze or happen to be in a loop. So it happen that if I install a module that need by react-native, npm will skip that loop/ cache stuff. So I install all dependencies before installing react-native and it works.

@syarul The change from PR #3193 hasn't been released yet: https://www.npmjs.com/package/react-native-cli

npm i react-native --verbose freezing is weird. Can you try using something like strace (or the equivalent on your OS) to see what the process is doing? Do you see any network traffic? If you wait long enough will it eventually finish?

I'm on windows 7, tested running the cli around morning 6-7am here seem's to be working alright, so does the npm i react-native --verbose, I believe it's network issue or lower latency on some region. It might be npm verb is not suited executed in poor network condition.

I also encountered this issue and it's root cause was also a previous aborted brew install attempt as described by @johngoren. Specifically, I ran sudo brew install watchman in a misunderstanding with Xcode having not installed correctly. brew cowardly aborted the install, hence the error. Running brew doctor did the trick.

@swastik thks!
After waiting a large amount of time thanks to watching the Activity Monitor... it works! XD
(I alse installed node-gyp firstly, and don't know if it matters.)

I zeroed down the problem to the cloning process for the repo git://github.com/facebook/react#b4e74e38e43ac53af8acd62c78c9213be0194245 timing out.

+1

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

@captain-miao +1

When executing react-native init AwesomeProject --verbose, I get these:

This will walk you through creating a new React Native project in D:\Developer\FrontEnd\AwesomeProject
Installing react-native package from npm...
events.js:154
      throw er; // Unhandled 'error' event
      ^

Error: spawn npm ENOENT
    at exports._errnoException (util.js:856:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at _combinedTickCallback (node.js:377:13)
    at process._tickCallback (node.js:401:11)
    at Function.Module.runMain (module.js:449:11)
    at startup (node.js:141:18)
    at node.js:933:3

node version: v5.7.1
os: win 10, x64
npm: 3.6.0
@mkonicek Any suggestion, thanks.

reinstall nodejs fix my issue :)

thanks --verbose works :)

The official doc Getting Started should add this "--verbose", or this will make new user confused a lot.

@gengjiawen I am also getting this error when trying to append --verbose (because you know, react-native init fails and I'd like to know why). How did you fix your problem ?

Updating node didn't do it for me.

@warpdesign don't use upgrade.you need to uninstall the old version,then install the new version.

@captain-miao it works!!!

This takes way longer than is typical for a command line operation that gives no status.

It would be terrific to see a message "Downloading 73mb of data. This could take awhile. Use --verbose to watch progress." rather than having to surf the web to this ticket to understand what it is doing.

Still having this problems, Installing RN0.33 with Node 6.50 npm 3.10.6

I don't know what do , been trying the last few days, diferent versions of RN without success. My internet connection is good and everything seems to be fine, just It doesn't install. Any way to install the package manually?

Thanks

I am experiencing this problem as of today. I've reinstalled brew, node, watchman, react-native-cli and when I do a verbose install, it just gets stuck after all the npm packages have installed (of which react is not one):

npm WARN [email protected] requires a peer of react@~15.3.1 but none was installed. npm verb npm verb If you need help, you may report this error at: npm verb <https://github.com/npm/npm/issues> npm verb exit [ 0, true ] npm info ok

It just sits there indefinitely. If I kill the process then all I have in my project folder is package.json and node_modules.

Any ideas?

_EDIT_ This is the first project I have tried to create since upgrading to macOS Sierra a week or so ago. Could this be at fault? I can run and work on existing projects under Sierra FYI, just can't create new ones.

@MichaelBurgess I have same problem, but also can't run existing project.
Mac OS Sierra, node 6.7.0, react-native-cli: 1.0.0, react-native: 0.34.1

@jeizsm check my SO post here, in case that helps.

@MichaelBurgess it helped, thanks

Something doesn't feel right with --verbose. I tried generating project both with and without --verbose flag. With - generating fails immediately. However - without the flag generator froze for a while, but project seems to be generated properly. I followed instructions from Getting Started guide (Windows 10, Chocolatey).

D:\Projekty\React>node -v
v6.7.0
D:\Projekty\React>npm -v
3.10.3
D:\Projekty\React>react-native init AwesomeProject --verbose
prompt: Directory AwesomeProject already exists. Continue?:  (no) yes
This will walk you through creating a new React Native project in D:\Projekty\React\AwesomeProject
Installing react-native package from npm...
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: spawn npm ENOENT
    at exports._errnoException (util.js:1036:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

D:\Projekty\React>react-native init AwesomeProject
prompt: Directory AwesomeProject already exists. Continue?:  (no) yes
This will walk you through creating a new React Native project in D:\Projekty\React\AwesomeProject
Installing react-native package from npm...
Setting up new React Native app in D:\Projekty\React\AwesomeProject
[email protected] D:\Projekty\React\AwesomeProject
`-- [email protected]

To run your app on iOS:
   cd D:\Projekty\React\AwesomeProject
   react-native run-ios
   - or -
   Open D:\Projekty\React\AwesomeProject\ios\AwesomeProject.xcodeproj in Xcode
   Hit the Run button
To run your app on Android:
   Have an Android emulator running (quickest way to get started), or a device connected
   cd D:\Projekty\React\AwesomeProject
   react-native run-android

I run --verbose, and it halts with this message:

npm WARN [email protected] requires a peer of react@~15.3.1 but none was installed.
npm verb exit [ 0, true ]
npm info ok

How come it doesn't install this as supposed to?

Edit: this problem was solved by running @MichaelBurgess suggestion above :)

For reference @MichaelBurgess suggests doing this (should save you a click) and that suggestion worked for me

rm -rf /usr/local/var/run/watchman/ && brew uninstall watchman && brew install watchman

references

@MichaelBurgess it helped, thanks

@MichaelBurgess i have same problem but on windows 8. any solution ? Thanks

react-native init <project> --verbose:
Verbose mode should maybe only display warnings and errors. It's incredibly cumbersome to scan through all those "verb" and "info" entries...

Looking through the verbose output, 151.101.40.162 keeps timing out.

@captain-miao 厉害了,我的哥

I've this problem when try first run

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> failed to find Build Tools revision 23.0.1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED
(node:4968) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot read property 'message' of undefined
(node:4968) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Node: v7.2.1
npm: 4.0.5
Windows 10 Pro x64

It's weird, I had been facing this issue when I realized I was trying to init a project called test and there was already a test folder inside the directory.

@fourcolors This worked for me! Your awesome dude 👍 Spend a day and half trying to figure it out.

restarting multiple times got it to work for me.

@captain-miao soluation work for me, I am in China.

Will anyone tell how to fix this??

Was this page helpful?
0 / 5 - 0 ratings