react-native: Init project hangs forever

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?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 9
  • Comments: 60 (16 by maintainers)

Commits related to this issue

Most upvoted comments

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

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

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

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.

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

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.

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 react-native@0.34.1 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.

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

npm WARN react-native@0.35.0 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 😃

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
AwesomeProject@0.0.1 D:\Projekty\React\AwesomeProject
`-- react@15.3.2

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

@captain-miao 厉害了,我的哥

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

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

@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

thanks --verbose works 😃

reinstall nodejs fix my issue 😃

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.

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.

Happening for me too.

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