Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load bundle: Cannot read property 'throwIfClosureRequired' of undefined #18962

Closed
3 tasks done
everdrone opened this issue Apr 20, 2018 · 63 comments
Closed
3 tasks done
Labels
Resolution: Locked This issue was locked by the bot. Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used.

Comments

@everdrone
Copy link

Environment

Environment:
OS: macOS High Sierra 10.13.4
Node: 9.5.0
Yarn: 1.5.1
npm: 5.8.0
Watchman: 4.9.0
Xcode: Xcode 9.3 Build version 9E145
Android Studio: Not Found

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.3 => 0.55.3

Steps to Reproduce

react-native init RNApp
# ...
react-native run-ios

or by opening RNApp.xcodeproj and hitting "run"

Expected Behavior

App launches normally on simulator

Actual Behavior

screen shot 2018-04-20 at 19 41 25

@duro
Copy link

duro commented Apr 20, 2018

This is throwing in my tests when upgrading to babel-preset-react-native to 5.0.0

Does not happen on 4.x of preset with 0.55.3 of react-native installed

@godinhoaugusto
Copy link

Same here

@husnaintahir
Copy link

same issue, happened just now

@Amar-HBCC
Copy link

Same issue happened in windows for run-android

@damiandizeo
Copy link

damiandizeo commented Apr 20, 2018

downgraded babel-preset-react-native to 4.0.0 and worked

@rondaniel00
Copy link

downgraded babel-preset-react-native to 4.0.0 and worked. same as the comments above.

@benoitgrelard
Copy link

First time I tried to play with react-native and I was greeted by the same bug too. So unfortunate for a first experience!! I can however confirm that downgrading babel-preset-react-native to 4.0.0 worked for me as well.

@andrewcpeltier
Copy link

How do you downgrade bable-preset-react-native to 4.0.0?

@Sapulidi
Copy link

Sapulidi commented Apr 20, 2018

@andrewcpeltier I just ran into this issue as well. Just edit the version number in your package.json file and npm install.

Edit: Worked for me as well by the way!

@VikAdvani
Copy link

VikAdvani commented Apr 20, 2018

Also confirming this. Seemed to happen as of today when running 'react-native init' and then running a new project in XCode. Downgrading babel-preset to 4.0 or below seems to work.

@achuvm
Copy link

achuvm commented Apr 20, 2018

@andrewcpeltier,

Open your package.json and change the devDependencies to:

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

Then run npm install.

@VikAdvani
Copy link

VikAdvani commented Apr 20, 2018

The babel-preset-react-native package was just published 6 hours ago, so somewhere in the RN dependency tree, it's pulling the latest version instead of a fixed one.

@andrewcpeltier
Copy link

Yeah looks like this started happening right after the publish. But that worked! Thanks a bunch for the help @achuvm and @Sapulidi !

@MattEhrlich
Copy link

I can confirm changing to "babel-preset-react-native": "4.0.0" also worked for me +1

@GantMan
Copy link
Contributor

GantMan commented Apr 21, 2018

What's funny is this wasn't changed that long ago: 34bd776

Odd how that came right through to everyone's CLI. Seems to me it should be tied to the specific RN version, not github?

@achuvm
Copy link

achuvm commented Apr 21, 2018

@GantMan

The issue are due to these lines in the react-native init script (copied below):

const jestDeps = (
`jest babel-jest babel-preset-react-native react-test-renderer@${reactVersion}`
);
if (yarnVersion) {
console.log('Adding Jest...');
execSync(`yarn add ${jestDeps} --dev --exact`, {stdio: 'inherit'});
} else {
console.log('Installing Jest...');
execSync(`npm install ${jestDeps} --save-dev --save-exact`, {stdio: 'inherit'});
}

You can see that the jestDeps are jest babel-jest babel-preset-react-native react-test-renderer@${reactVersion}, but only the react-test-renderer is given a version. Which means every time anyone runs the react-native init script, it'll install the latest jest, babel-jest and babel-preset-react-native versions from npm as devDependencies.

The change you see shouldn't actually affect why we see this bug, but rather, it's the fact that version 5.0.0 of babel-preset-react-native was made the latest release about 9 hours ago: https://www.npmjs.com/package/babel-preset-react-native

That also explains why this bug was created 8 hours ago.

@hoangvuanhdevelopervn
Copy link

hoangvuanhdevelopervn commented Apr 21, 2018

Change "babel-preset-react-native": "^4.0.0" and it work for me

@jaimemendozadev
Copy link

I'm still get the same red error screen if I set the dev dependency to "babel-preset-react-native": "4.0.0". Anybody else running into the same issue?

@jaimemendozadev
Copy link

Nvm, now it works. Weird. Thanks everyone! 😄

@xellDart
Copy link

some here, i changed to 4 but error still

@mgtitimoli
Copy link

mgtitimoli commented Apr 21, 2018

This issue is caused by the fact babel-preset-react-native depends on babel@v7.0.0-beta.40.

This version had an issue on babel-plugin-transform-block-scoping, as at this stage babel-helper-plugin-utils had not yet been created, and this one (created on v7.0.0-beta.41) is used to set a default {} for the options when they are not present (see here), that's the case for babel-plugin-transform-block-scoping declared here.

The only alternative would be to use yarn resolutions and lock all the babel depedencies to latest, but sadly this doesn't work either, as metro-bundler is in the middle of the migration to babel 7 and they are still using babel-core (core package from babel version 6), so when you run the packager, everything breaks.

So based on all this, I believe that the most sane alternative is to wait for babel-preset-react-native and metro-bundler to update their babel dependencies to latest and meanwhile keep using v4.0.0.

@danielcolgan
Copy link

danielcolgan commented Apr 21, 2018

@duro Downgraded babel-preset-react-native to 4.0.0 and worked! Thank you!

@Nitingadhiya
Copy link

If not work try this solution.
i) delete node_module folder.
ii) Open your package.json and change the devDependencies to:

"devDependencies": {
...
"babel-preset-react-native": "4.0.0",
...
},
Then run npm install.
It's worked for me.

@rassemdev
Copy link

drowgrading to "babel-preset-react-native": "4.0.0" didn't work for me :(

@Owl7
Copy link

Owl7 commented Apr 21, 2018

I changed to 4 but error still.

@pritam-patil
Copy link

pritam-patil commented Apr 21, 2018

For those who have updated the "babel-preset-react-native" to version "4.0.0", and still seeing the issue:

  1. Run npm install again, before running the app with react-native run-android or react-native run-ios
  2. If you still see the issue, clear 'node_modules' directory, run rm -rf node_modules/ from your project directory and repeat step 1.

Worked for me with the environment:

  • OS: Ubuntu 17.04 64-bit
  • Project dependancies (package.json):
"dependencies": {
    "react": "16.3.1",
    "react-native": "0.55.3"
  },
  "devDependencies": {
    "babel-jest": "22.4.3",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.4.3",
    "react-test-renderer": "16.3.1"
  }

@namlehoangdev
Copy link

Owl7 Did you run "npm install" yet ?

@Owl7
Copy link

Owl7 commented Apr 21, 2018

@lehoangnam97 of course

@Owl7
Copy link

Owl7 commented Apr 21, 2018

@pritam-patil error still. 😢

@Owl7
Copy link

Owl7 commented Apr 21, 2018

@pritam-patil @lehoangnam97 Started work, I restarted the computer. 😄

@SamilMehdiyev
Copy link

Hi everyone,
To fix problem I did following steps:

  1. remove node_modules folder : rm -rf node_modules/ and package-lock.json file
  2. change "babel-preset-react-native": "4.0.0"
  3. run npm install
  4. restart OS. Aftering restart 'cd' to app folder and react-native run-ios.

Hope it will help.

@marlonnardi
Copy link

marlonnardi commented Apr 21, 2018

Open your package.json and change the devDependencies to:

"devDependencies": {
...
"babel-preset-react-native": "4.0.0",
...
},
Then run npm install.

Thanks @achuvm, this worked...

turnipdabeets added a commit to turnipdabeets/travel that referenced this issue Apr 21, 2018
turnipdabeets added a commit to turnipdabeets/travel that referenced this issue Apr 21, 2018
@mortezaalizadeh
Copy link

same issue, happened just now after upgrading to version 5

@turnipdabeets
Copy link

@abhijitnukalapati - yes I am able to run the app after changing babel-preset-react-native to "4.0.0"
Try to change package.json and then re-install node modules
rm -rf node_modules && npm i

@abhisheksingh1
Copy link

Open your package.json and change the devDependencies to:

"devDependencies": {
...
"babel-preset-react-native": "4.0.0",
...
},
Then run npm install.
Don't forgot to start yarn once again - yarn start
Thanks @turnipdabeets, it's working.

@macloving
Copy link

I am very sorry sorry, but how is this do?

This is throwing in my tests when upgrading to babel-preset-react-native to 5.0.0
Does not happen on 4.x of preset with 0.55.3 of react-native installed

@velobuff
Copy link

velobuff commented Apr 22, 2018

It also helps to kill Metro bundler and restart your Simulator. I even deleted the app from my iOS simulator as well just in case there was code cached somewhere else.

@jinaddavid
Copy link

After changing change change "babel-preset-react-native": "5.0.0" To "babel-preset-react-native": "4.0.0"

and run npm install. its works for me

Thanks so much

@Jimato
Copy link

Jimato commented Apr 22, 2018

"babel-preset-react-native": "4.0.0"
it works, thanks!!!

@nikthakkar
Copy link

nikthakkar commented Apr 22, 2018

@marksturm Thanks for the command. That worked for me finally.
Only one thing if you are using npm version > 5 then use this
watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean --force && npm install && npm start -- --reset-cache

@adriantoari
Copy link

Thanks... It works..
"babel-preset-react-native": "4.0.0"

@hiradary
Copy link

@marksturm you just saved my life! <3
thanks a lot man, that was very helpful.

@thiennhank9
Copy link

u guys saved me, thank you so much

@stevemu
Copy link

stevemu commented Apr 22, 2018

Using "babel-preset-react-native": "4.0.0" works for me. Thank you!

@uneeb123
Copy link

What's the root cause?

@fcastaneda9725
Copy link

The same problem, i solved dowgrading "babel-preset-react-native": "4.0.0" and restanting my computer, i'm on Ubuntu 17.10

@grabbou
Copy link
Contributor

grabbou commented Apr 23, 2018

Will get this fixed in next minor release today.

@kitze
Copy link

kitze commented Apr 23, 2018

The legend says that one day you will be able to generate a react-native project without solving random errors.

@grabbou
Copy link
Contributor

grabbou commented Apr 23, 2018

@chuwuwang I am going to delete your comment and report this activity to Github. We do not accept such behavior that is way below the accepted standards. If React Native pisses you off, just don't use it. It's free world.

@facebook facebook deleted a comment from chuwuwang Apr 23, 2018
@AlagicAmir
Copy link

AlagicAmir commented Apr 23, 2018

downgrade babbel and run npm install is not helping ... I had to restart computer to make it work

@facebook facebook locked as too heated and limited conversation to collaborators Apr 23, 2018
@kelset kelset added the Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used. label Dec 18, 2018
@kelset
Copy link
Contributor

kelset commented Dec 18, 2018

(closing as inactive, there have been new issues on the bundler subject and since this issue many things changed)

(if necessary open a new issue)

@kelset kelset closed this as completed Dec 18, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Dec 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot. Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used.
Projects
None yet
Development

No branches or pull requests