Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 432
J. Hesters Avatar asked Jul 04 '18 17:07

J. Hesters


2 Answers

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

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

like image 114
aydnep Avatar answered Nov 01 '22 12:11

aydnep


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

like image 43
Satya Mishra Avatar answered Nov 01 '22 12:11

Satya Mishra