2017-02-23 51 views
5

初始化反应,本机应用程序我得到下面的语法错误,当我使用初始化react-native init MyApp同时使用CLI

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) 

我不知道为什么会这样突然的一个应用程序中的语法错误。之前它工作得很好。我想我在修补时误删了一些配置文件。

+0

我也遇到过这种情况。版本是:react-native-cli:2.0.1,react-native:0.41.2,yarn:0.20.3,node:v7.6.0 – IAmFledge

回答

3

更新

他们更新包,以便删除您的节点模块并重新安装。 rm -rf node_modulesnpm installMore info

我从getting started安装AwesomeProject。

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

它的工作!

原始

的问题已被提交:https://github.com/facebook/react-native/issues/12542

npm uninstall babylon && npm install [email protected] 或更新的package.json文件,包括"babylon": "6.15.0"

+0

给出的链接没有帮助。他们只是增加问题计数器... –

+0

当一个贡献者回应时,它将在StackOverflow之前的那条链接上。我并不是说要在评论中加上“+1”,我是说这将是寻找解决方案的最佳选择。 – Keith

0

在我的情况下(在Windows7的),没有安装蟒蛇。安装Python2之后,react-native init命令正常工作。