5

I am getting the following syntax error when I initialize an app using react-native init MyApp

    SyntaxError: /Users/MyAccount/RNProjects/app/node_modules/react-native/packager/react-packager/src/node-haste/index.js: You can only use Class Properties when the 'classProperties' plugin is enabled. (389:2)
  387 |   }
  388 |
> 389 |   static Cache;
      |   ^
  390 |   static Module;
  391 |   static Polyfill;
  392 |   static getAssetDataFromName;
    at Parser.pp$5.raise (/Users/MyAccount/RNProjects/app/node_modules/babylon/lib/index.js:4380:13)

I have no idea why this is happening all of a sudden. It was working all fine before. I guess I deleted some config files by mistake while tinkering.

UtkarshPramodGupta
  • 7,486
  • 7
  • 30
  • 54
  • I'm also experiencing this. versions are: react-native-cli: 2.0.1, react-native: 0.41.2, yarn: 0.20.3, node: v7.6.0 – RemoteCTO Feb 23 '17 at 13:43
  • This link [link ](https://stackoverflow.com/questions/41051572/react-native-init-awesomeproject-throwing-syntaxerror/51385120#51385120) can be useful to you – Mahdi Bashirpour Jul 17 '18 at 15:26

2 Answers2

3

Update

They have updated the package so remove your node modules and reinstall them. rm -rf node_modules and npm install More info

I was installing the AwesomeProject from getting started.

$ rm -rf AwesomeProject/
$ react-native init AwesomeProject

And it worked!

Original

An issue has been filed: https://github.com/facebook/react-native/issues/12542

npm uninstall babylon && npm install babylon@6.15.0 or update the package.json file to include "babylon": "6.15.0"

Keith
  • 637
  • 1
  • 8
  • 23
  • Given link is not helpful. They are just increasing problem counters... – Arun Kumar Feb 23 '17 at 14:10
  • When a contributor responses, it will be on that that link way before it is on StackOverflow. I'm not saying add `+1` to the comments, I'm saying this will be the best spot to look for a solution. – Keith Feb 23 '17 at 14:16
0

In my case (on windows7), python was not installed. After installing Python2 react-native init command is working fine.

Arun Kumar
  • 323
  • 1
  • 4
  • 15