Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native starter project bundling fails with Unexpected Token error

I'm trying to create my first React Native app for Android using the instructions on https://facebook.github.io/react-native/docs/getting-started.html. After setting up the dependencies and connecting my Android device, I ran

react-native init app
cd app
react-native run-android

This starts the React Packager, which fails to bundle with this error:

error: bundling failed: "TransformError: /Users/luky/dev/app/index.android.js: Unexpected token ) (While processing preset: \"/Users/luky/dev/app/node_modules/babel-preset-react-native/index.js\")"

I am using:

  • OSX El Capitan 10.11.6.
  • node version 6.9.2
  • react-native version 0.47.1.

I pushed my generated project, including node_modules, to Github in case it helps: https://github.com/luky1971/react-native-app

Does anyone know why I might be getting an Unexpected token error? Any help would be greatly appreciated!

like image 372
ahnafisenough Avatar asked Feb 03 '26 15:02

ahnafisenough


1 Answers

I got the same thing, it looks like the latest version of the babel preset for react native has some bugs (version 3.0.0). I went into my package.json and replaced the latest version with this:

"babel-preset-react-native": "2.1.0".

then I deleted the node_modules directory and ran npm install and it worked.

like image 94
Sean McManus Avatar answered Feb 06 '26 08:02

Sean McManus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!