Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native: Failed to load bundle. Cannot read property 'throwlfClosureRequired'

The app installs and opens but right when it opens this red screen appears with the below error message.

TBH I am not quite sure what I am doing and I really need some help. I was able to get my other project to work but when I started my second project this came up when trying to run the code. The code is just the basic code you get when you run: react-native init projectName

Error when trying to setup project in react-native.

like image 769
Jonathan Ishii Avatar asked Apr 21 '18 00:04

Jonathan Ishii


5 Answers

Change the version of "babel-preset-react-native" to "4.0.0". For the lastest version 5.0.0, the issue arises.

  1. Run npm install after the version change. Then start the emulator.
  2. Even then if you face issue, delete your node_modules directory, repeat step 1.
  3. Restart your machine if you see the issue again even after all tries.

Check github issue

like image 164
pritam Avatar answered Nov 14 '22 15:11

pritam


I got the above mentioned error just now. I am using React Native v0.57 and my json file had this

 {
  "name": "AwesomeProject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.5.0",
    "react-native": "0.57.1"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.45.6",
    "react-test-renderer": "16.5.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

I added "babel-preset-react-native": "4.0.0", and removed "metro-react-native-babel-preset": "0.45.6" in the "devDependencies" and the error was resolved.

like image 4
Ronique Ricketts Avatar answered Nov 14 '22 16:11

Ronique Ricketts


Jonathan's solution worked for me as well:

Fixed. babel pushed an update that pushed to 5.0.0. set your presets to 4.0.0 and it will fix it.

https://github.com/facebook/react-native/issues/18962

like image 1
Eric Kanner Avatar answered Nov 14 '22 16:11

Eric Kanner


I have upgraded to

"react-native": 0.57.7

"metro-react-native-babel-preset": "0.48.5",

Now the bundle is loading as expected.

like image 1
Srikanth Kyatham Avatar answered Nov 14 '22 15:11

Srikanth Kyatham


My current version:

"react-native": "0.57.8",
"metro-react-native-babel-preset": "0.51.1",

Here how I fixed:

  1. add

    "devDependencies": {
      "babel-preset-react-native": "4.0.0"
    },
    
  2. remove node_modules

  3. npm install

Voilà! It works!

like image 1
Saviah Kao Avatar answered Nov 14 '22 17:11

Saviah Kao