2017-02-23 49 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命令正常工作。