Metro Bundler immediately closes after react-native run-android
Environment
System:
OS: Windows 10
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 8.99 GB / 15.89 GB
Binaries:
Node: 10.16.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.16.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
SDKs:
Android SDK:
Android NDK: 18.1.5063045
IDEs:
Android Studio: Version 3.3.0.0 AI-182.5107.16.33.5264788
react-native-cli: 2.0.1
react-native: 0.60.0
Description
Doing yarn react-native run-android opens the metro bundler but it immediately closes. Don't know if its a bug with the cli or the metro itself. This only happens on Windows, I think.
Things I have tried:
- Restarting my system
- Clearing cache etc.
Reproducible Demo
- Create a new project using
react-native init - Run
yarn react-native run-android
Hey guys worked with the change in the .bat file ok, vlw but once thanks. Sorry for the inconvenience
Closed via https://github.com/react-native-community/cli/pull/489. Published in 2.1.1, please try give it a try (see how to update the CLI)
The changes in the .bat file made the metro bundler run without closing immediately. However, the metro bundler takes too long to load the dependency graph and then the app crashes in the emulator as soon as the BUNDLE process reaches 100%.
I'm running React Native 0.60 and I've updated @react-native-community/cli to 2.1.2
@naderabdalghani I suppose you use Node >=12.5, please downgrade to 12.4. See https://github.com/react-native-community/cli/issues/485#issuecomment-509210382
Memory usage has significantly improved after downgrading to node 12.4.0. However, the app still crashes after BUNDLE process reaches 100% or I manually open it

@naderabdalghani That's different issue, likely caused by configuration in your app. Please try a new project with a set of libraries you use and try to find the bug. If you're then sure it's something inside React Native or CLI, please file an issue accordingly.
Same error on Linux (Elementary OS) After running react-native start, i've got a blank screen. For a temporary fix, this work's fine.
Metro cannot start, so I run react-native start then I got this error, anyone know how to fix this?
events.js:174
throw er; // Unhandled 'error' event
^
Error: UNKNOWN: unknown error, lstat 'D:\WarungPintar\kurir-app\node_modules\.bin\JSONStream'
Emitted 'error' event at:
at NodeWatcher.checkedEmitError (D:\WarungPintar\kurir-app\node_modules\metro\node_modules\sane\src\node_watcher.js:143:12)
at Walker.emit (events.js:198:13)
at D:\WarungPintar\kurir-app\node_modules\walker\lib\walker.js:52:12
at D:\WarungPintar\kurir-app\node_modules\graceful-fs\polyfills.js:282:31
at FSReqWrap.oncomplete (fs.js:153:21)
I have recently upgraded to RN 0.60.0 from 0.57, after running "react-native run-android" the configurations from build.grade executes successfully. But the metro bundler launches and doesn't loads and says it's done. The app crashes, as the metro bundler doesn't run.
Any approach to fix this? @thymikee

Does running react-native start first help? Also, if you use Node 12, make sure to upgrade to 12.9+, there was a bug in V8 that affected Metro.
Same issue here.
System: OS: macOS 10.14.6 CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz Memory: 2.19 GB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.9.0 - /usr/local/bin/node Yarn: 1.16.0 - /usr/local/bin/yarn npm: 6.10.2 - /usr/local/bin/npm SDKs: iOS SDK: Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2 IDEs: Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild npmPackages: react: 16.8.6 => 16.8.6 react-native: 0.60.5 => 0.60.5 npmGlobalPackages: react-native-cli: 2.0.1
as a workaround, it's works when I do "yarn start" first (or npm start)
@thymikee trying out that I got the following errors:

My system's node version is : 12.9.0 @thymikee
Did anyone face a same issue? Any particular approach to follow and fix this? Please kindly update.
Did you actually read the error message? The registry is down for some reason and it cannot download Android deps. It's not related to Metro anyhow.
Hi @thymikee I encountered that yesterday and tried making few changes. Now, as you can see in the picture below the build is successful, but the metro bundler doesn't load.

Looks like Metro is running fine (see the "Loading dependency graph, done." message). It's possible that your app is not able to connect to it. See https://stackoverflow.com/questions/42064283/react-nativecould-not-connect-to-development-server-on-android or similar.
I have the same issue as @abhirup03 . There is no error message, just that it refuses to actually create the bundle. No error given. PS, I'm on a mac. Have tried node 10, 11, 12.9, nothing helps
I was using node 12.13.0 and facing the same issue. Now I downgraded it to 10.15.0 and metro bundle is running without fail.
@naderabdalghani I suppose you use Node >=12.5, please downgrade to 12.4. See #485 (comment)
It worked for me. Thanks