Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native SyntaxError in node_modules/react-native/index.js: Unexpected token, expected "{" (13:7) on Android Build

I have initialized a react-native-project and converted it to use TypeScript. I also setup the project to compile to web, android, and ios. Webpack was installed to launch the web version. I got everything working on Web and iOS just fine but when I run yarn android and build to android I get a Syntax error in the Metro window and on the android simulator coming from the index.js file inside the react-native project under node_modules.

This is only happening on Android. I have installed a number of babel plugins and presets so I'm not sure why this index.js file is not working for Android but works correctly on iOS. Any help would be great. I have uploaded the project in a public repo.

I have the starter project available in a github repo so you can pull down my exact setup. https://github.com/hybridmindset/liveapp

I am running on a Mac OS version Catalina 10.15.4 Node v14.0.0

Metro server window with Error

Android Simulator Window with Error

like image 288
Lavon Woods Avatar asked Nov 07 '22 08:11

Lavon Woods


1 Answers

This might help. Here is my .babelrc: { "presets": [ "@babel/preset-env", "@babel/preset-react", "@babel/preset-flow" ] }

https://github.com/babel/babel/issues/9351

like image 107
mukesh Avatar answered Nov 15 '22 10:11

mukesh