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
@naderabdalghani I suppose you use Node >=12.5, please downgrade to 12.4. See #485 (comment)
It worked for me. Thanks
Thanks It worked for me. running 13.1.0 not worked. downgraded to 12.4.0 and it worked. :)
I also downgraded to 12.4.0 and it worked
If you are using chocolatey on windows
choco uninstall nodejs
then
choco install nodejs --version 12.4.0
Same here, downgrading node from v12.13.1 to 12.4.0 to work
I have the same issue with version 3.0.4, which is the latest right now, should I open a new issue?
I also downgraded to 12.4.0 and it worked
If you are using chocolatey on windows
choco uninstall nodejsthenchoco install nodejs --version 12.4.0
Confirmed that it's working aswell.
@zenz it's not about rmeoving the file, but doing this diff:
-node "%~dp0..\cli.js" --projectRoot ../../../ start +node "%~dp0..\cli.js" start
where can i find the file to modify
nodemodules/react-native/scripts/launchPackager.bat
Actually, this work for me. https://github.com/expo/expo-cli/issues/1074#issuecomment-546167583
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.5264788react-native-cli: 2.0.1 react-native: 0.60.0Description
Doing
yarn react-native run-androidopens themetro bundlerbut it immediately closes. Don't know if its a bug with theclior themetroitself. 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
Open Your Project Folder in IDE like Visual Studio Code etc
Click on node_modules folder
Click on metro-config folder
Click on src folder
Click on default folder
Open blacklist.js file and replace the following code
var sharedBlacklist = [
/node_modules[/\\]react[/\\]dist[/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
With
var sharedBlacklist = [
/node_modules[\/\\]react[\/\\]dist[\/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
guys any other solution? I tried everything but my bundler close immediately and unable to run the app. it was working fine but I just reinstall window and below is the configuration:
System: OS: Windows 10 Binaries: Node: 12.4.0 npm: 6.9.0 react-native-cli: 2.0.1 react-native: 0.58.3
I really need this fix. Any quick help would appreciate it
What is the status of this? I'm still experiencing this error, the metro bundle closing with running react-native run-android on node 12.9.1
In my case I intentionally uninstalled app from emulator and faced the issue. Tried all options but changing app name is the best option. Else reinstall android studio with a new emulator.
Try changing app name in app.Json, build.gradle, AndroidManifest.xml in both debug and main folders
In mac env I also had the same issue and the solution was:
brew install nvm && brew unlink node && nvm install v10.23.0 && nvm use v10.23.0 && nvm alias default v10.23.0
then react-native run-android worked like a charm no single error.
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.5264788react-native-cli: 2.0.1 react-native: 0.60.0Description
Doing
yarn react-native run-androidopens themetro bundlerbut it immediately closes. Don't know if its a bug with theclior themetroitself. 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-androidOpen Your Project Folder in IDE like Visual Studio Code etc
Click on node_modules folder
Click on metro-config folder
Click on src folder
Click on default folder
Open blacklist.js file and replace the following code
var sharedBlacklist = [ /node_modules[/\\]react[/\\]dist[/\\].*/, /website\/node_modules\/.*/, /heapCapture\/bundle\.js/, /.*\/__tests__\/.*/ ];Withvar sharedBlacklist = [ /node_modules[\/\\]react[\/\\]dist[\/\\].*/, /website\/node_modules\/.*/, /heapCapture\/bundle\.js/, /.*\/__tests__\/.*/ ];
I'm using node v16.3.0 and this adjustment you posted made it work.. tks
For me it was because I had "type": "module" in my package.json
I was having this issue but wasn't able to resolve it with any of the earlier solutions. In the end it turned out my computer had a process binding the default port. Running with a custom port worked great until I restarted, then things were back to normal.
npx react-native run-android --port 8283 (random port)
i always this same problem and the error is usually some file in node_modules was unavailable, if i just continue to press play from android studio it eventually works but sometimes it takes up to 10 tries. any ideas ?
@cparello Switch to Flutter for 100% guaranteed builds, Android and iOS, every single time!
I got bored to fight the compiler, did the switch and never looked back!
How is this still an issue? Its such a waste of time to compile the code from like 15th time because the metro keeps exiting when the build is at 95-99%. I updated the package but not fixed, tried various fixes from the comments above - nothing.