捆绑失败的React Native

时间:2018-07-08 10:12:36

标签: javascript react-native

当我键入react-native run-android时,出现以下错误:

Loading dependency graph, done.
error: bundling failed: SyntaxError in C:\Users\User\Desktop\nodejstest\mobile\node_modules\react-native\Libraries\Components\AccessibilityInfo\Accessib
ilityInfo.android.js: C:/Users/User/Desktop/nodejstest/mobile/node_modul
es/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android
.js: Unexpected token, expected ; (19:5)
  17 | const TOUCH_EXPLORATION_EVENT = 'touchExplorationDidChange';
  18 |
> 19 | type ChangeEventName = $Enum<{
     |      ^
  20 |   change: string,
  21 | }>;
  22 |
 BUNDLE  [android, dev] ./index.js ░░░░░░░░░░░░░░░░ 2.6% (18/112), failed.

调试几个小时。 Kinda是React Native的新功能。我怎样才能解决这个问题 ?

2 个答案:

答案 0 :(得分:0)

请删除node_modules文件夹并运行以下命令:
npm install
npm start--重置缓存

答案 1 :(得分:0)

虽然我安装了package.json中最新的react-native,但我的react-native cli工具已过时。
我所做的是“本机升级”,然后收到提示信息,提示我的.babelrc已过时。
我确认了所有提示,现在可以正常工作了,这个问题困扰了48小时

相关问题