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.

halfer
  • 19,824
  • 17
  • 99
  • 186
J. Hesters
  • 13,117
  • 31
  • 133
  • 249

2 Answers2

35

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

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

Niellles
  • 868
  • 10
  • 27
aydnep
  • 366
  • 3
  • 4
  • 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 :( – J. Hesters Jul 05 '18 at 07:01
  • 2
    React-Native 0.56 needs ```babel-preset-react-native``` 5.0.0, https://github.com/facebook/react-native/issues/20042. – Sandip Nirmal Jul 05 '18 at 16:00
  • 1
    FWIW I needed a restart before the error cleared out once upgrading babel-preset-react-native – Dave Cole Jul 09 '18 at 22:48
  • 2
    `npm i babel-preset-react-native --save-dev` to upgrade – Gürol Canbek Aug 25 '18 at 11:59
  • run `yarn add babel-preset-react-native@5.0.0 --dev` If you continue to see yarn try to install 4.0.0 – dotcomXY Sep 04 '18 at 03:22
  • 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. – MacK May 20 '19 at 12:25
1

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

Satya Mishra
  • 111
  • 1
  • 2