cli icon indicating copy to clipboard operation
cli copied to clipboard

Metro Bundler immediately closes after react-native run-android

Open thecodrr opened this issue 7 years ago • 85 comments

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:

  1. Restarting my system
  2. Clearing cache etc.

Reproducible Demo

  1. Create a new project using react-native init
  2. Run yarn react-native run-android

thecodrr avatar Jul 05 '19 14:07 thecodrr

Hey guys worked with the change in the .bat file ok, vlw but once thanks. Sorry for the inconvenience

Andersonfrfilho avatar Jul 07 '19 00:07 Andersonfrfilho

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)

thymikee avatar Jul 07 '19 08:07 thymikee

image 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

naderabdelghany avatar Jul 08 '19 16:07 naderabdelghany

@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

thymikee avatar Jul 08 '19 16:07 thymikee

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 image

naderabdelghany avatar Jul 08 '19 17:07 naderabdelghany

@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.

thymikee avatar Jul 08 '19 17:07 thymikee

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.

DaviRJ avatar Jul 11 '19 00:07 DaviRJ

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)

arryanggaputra avatar Jul 11 '19 06:07 arryanggaputra

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 Screen Shot 2019-08-23 at 10 43 46 AM

abhirup03 avatar Aug 23 '19 05:08 abhirup03

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.

thymikee avatar Aug 23 '19 07:08 thymikee

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)

GaetanB999 avatar Aug 23 '19 12:08 GaetanB999

@thymikee trying out that I got the following errors: Screen Shot 2019-08-25 at 3 19 46 PM

abhirup03 avatar Aug 25 '19 09:08 abhirup03

My system's node version is : 12.9.0 @thymikee

abhirup03 avatar Aug 25 '19 19:08 abhirup03

Did anyone face a same issue? Any particular approach to follow and fix this? Please kindly update.

abhirup03 avatar Aug 26 '19 04:08 abhirup03

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.

thymikee avatar Aug 26 '19 05:08 thymikee

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. Screen Shot 2019-08-26 at 11 01 15 AM

abhirup03 avatar Aug 26 '19 05:08 abhirup03

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.

thymikee avatar Aug 26 '19 06:08 thymikee

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

jacquesdev avatar Sep 12 '19 09:09 jacquesdev

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.

JindalPrashant avatar Nov 15 '19 18:11 JindalPrashant

@naderabdalghani I suppose you use Node >=12.5, please downgrade to 12.4. See #485 (comment)

It worked for me. Thanks

JindalPrashant avatar Nov 15 '19 18:11 JindalPrashant