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
modify it like this, solves the problem:
@echo off
title Metro Bundler
call .packager.bat
cd ../../../
node "%~dp0..\cli.js" start
pause
exit
hard coding it to swith to root directory.
I think that makes sense, this is similar to what Linux script does: https://github.com/facebook/react-native/blob/master/scripts/launchPackager.command
@thymikee should I add it to the PR?
Let's make sure it works as intended, and then yes
@thymikee after adding the cd command, the packager loads and bundles successfully. So it is working.
After the cd ../../../ command, it works successfully!
Hey guys, still having problems... Today I started a new RN project, after the setupe, my Metro Bundler opens, starts, but it keeps in the "Loading Depedency Graph..." screen. It starts to consume my computer memory like crazy and everything gets really slow, but the Metro Bundler don't finish the Dependency Graph proccess. Any workaround to that?
P.S.: I already tried the steps above!
@Inovassist-dev kill all background node process, run react-native start is it running correct or not?
Thx, zenz I have this problem
Environment
System:
OS: Windows 10
Yarn version:
1.16.0
Node version:
10.15.3
Platform:
win32 x64
react-native --version
react-native-cli: 2.0.1
react-native: 0.60.0
react-native run-android
`D:\ADS\curso-react-native\ReactNativeReduxGraphQl>react-native run-android info Starting JS server... info Installing the app...
Task :app:installDebug 01:20:29 V/ddms: execute: running am get-config 01:20:29 V/ddms: execute 'am get-config' on 'emulator-5554' : EOF hit. Read: -1 01:20:29 V/ddms: execute: returning Installing APK 'app-debug.apk' on 'Pixel_3_API_28_86(AVD) - 9' for app:debug 01:20:29 D/app-debug.apk: Uploading app-debug.apk onto device 'emulator-5554' 01:20:29 D/Device: Uploading file onto device 'emulator-5554' 01:20:29 D/ddms: Reading file permision of D:\ADS\curso-react-native\ReactNativeReduxGraphQl\android\app\build\outputs\apk\debug\app-debug.apk as: rwx------ 01:20:29 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk" 01:20:30 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1 01:20:30 V/ddms: execute: returning 01:20:30 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk" 01:20:30 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1 01:20:30 V/ddms: execute: returning Installed on 1 device.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 3s 27 actionable tasks: 2 executed, 25 up-to-date 'C:\Users\Anderson' n�o � reconhecido como um comando interno ou externo, um programa oper�vel ou um arquivo em lotes. info Connecting to the development server... info Starting the app... Starting: Intent { cmp=com.reactnativereduxgraphql/.MainActivity }
D:\ADS\curso-react-native\ReactNativeReduxGraphQl>`
Works only by executing commands 1st react-native start 2nd react-native run-android
or manually the project repositori https://github.com/Andersonfrfilho/ReactNativeReduxGraphQl
@Andersonfrfilho I don't see any error in your output. What's the problem?
I run @Andersonfrfilho 's code with modified launchPackager.bat.
No errors and it runs well.

So I think he didn't modify the launchPackager.bat file
Just created a PR (#489) that should fix this for now. @thymikee waiting for your review.
@theweavrs good, this PR moves the commands into same place.
Just created a PR (#489) that should fix this for now. @thymikee waiting for your review.
when i applied the pr, i get a "fs is not defined error"
As a temporary solution, I've found a little workaround :
-
Run the Metro Bundler manually with
react-native start -
Then run as usual. I'm doing
react-native run-android
You might be stuck with a blank screen after this, meaning you have to run again after Metro generated a build/bundle once. So force close the app, and then run as usual again while keeping the Metro Bundler running in the background.
You may also have to update your version of react-native-cli to 2.0.2
Good as I saw the difficulty to find the error I posted a video showing what is happening now when I execute the commands https://youtu.be/6qiBeKnHYSc thank you to the impenetrate for trying to solve the problem
@Andersonfrfilho Please read above comments to find out the temporary solution. Sometimes the official release will be very late. Modify node_modules/react-native/scripts/launchPackager.bat Change the contents like below:
@echo off
title Metro Bundler
call .packager.bat
cd ../../../
node "%~dp0..\cli.js" start
pause
exit
Again I apologize for the inconvenience, but there is neither this executable nor the file in my node_modules
img: https://ibb.co/kBnmCzG
and https://ibb.co/9y2ddQt
@Andersonfrfilho the path is ./node_modules/react-native/scripts/launchPackager.bat, please read carefully.
sorry, I just review here I'll try, thx