React Native crashes after upgrade to version 0.56. Possible Babel issue?
Asked Answered
B

2

14

After upgrading my React Native project using react-native-git-upgrade I get the following error:

error: bundling failed: TypeError: Cannot read property 'bindings' of null
    at Scope.moveBindingTo (/Users/jan/Startup/react-native/ordersome/node_modules/@babel/traverse/lib/scope/index.js:978:13)
    at BlockScoping.updateScopeInfo (/Users/jan/Startup/react-native/ordersome/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:364:17)
    at BlockScoping.run (/Users/jan/Startup/react-native/ordersome/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:330:12)
    at PluginPass.BlockStatementSwitchStatementProgram (/Users/jan/Startup/react-native/ordersome/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:70:24)
    at newFn (/Users/jan/Startup/react-native/ordersome/node_modules/@babel/traverse/lib/visitors.js:237:21)
    at NodePath._call (/Users/jan/Startup/react-native/ordersome/node_modules/@babel/traverse/lib/path/context.js:65:20)
    at NodePath.call (/Users/jan/Startup/react-native/ordersome/node_modules/@babel/traverse/lib/path/context.js:40:17)
    at NodePath.visit (/Users/jan/Startup/react-native/ordersome/node_modules/@babel/traverse/lib/path/context.js:100:12)
    at TraversalContext.visitQueue (/Users/jan/Startup/react-native/ordersome/node_modules/@babel/traverse/lib/context.js:142:16)

It seems like this problem has something to do with babel. I restarted metro as well as my simulator, but that did not change a thing. Also here are all the packages I've installed that have anything to do with babel (package.json):

"babel-eslint": "^8.2.5",
"babel-jest": "23.2.0",
"babel-preset-react-native": "4.0.0",

And here is my .babelrc:

{
  "presets": ["react-native"]
}

I generated the project using react-native init when it was still at 0.55.

Blow answered 4/7, 2018 at 17:11 Comment(0)
A
35

Try to update the version forbabel-preset-react-native in your package.json like so:

"babel-preset-react-native": "^5".

Aquilar answered 4/7, 2018 at 18:44 Comment(6)
I will just accept this as an answer, but I fixed it another way. I created a new project using react-native init and copied all my code there :(Blow
React-Native 0.56 needs babel-preset-react-native 5.0.0, github.com/facebook/react-native/issues/20042.Aqualung
FWIW I needed a restart before the error cleared out once upgrading babel-preset-react-nativeLatterday
npm i babel-preset-react-native --save-dev to upgradeSven
run yarn add [email protected] --dev If you continue to see yarn try to install 4.0.0Automate
For the latecomers from google upgrading to expo-cli and react-native 59, along with this make sure to delete the old .babelrc and replace it with the new babel.config.js, on top of that make sure it is using the right preset and then follow the instructions expo-cli gives to you to clean watchman and the compilation caches.Figurant
S
1

According the babel-preset-react-native entry on npmjs.org, it is obsolete. metro-react-native-babel-preset is the replacement.

Shoelace answered 12/5, 2019 at 15:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.