2017-06-02 206 views
0

当我尝试在设备上运行我的android应用程序(react-native)时发生以下错误。java.lang.RuntimeException:com.facebook.react.devsupport.JSException:SyntaxError:意外标记':'。解析错误

我有最新的反应依赖关系: “反应”: “〜16.0.0-alpha.6” “反应过来天然的”: “〜0.44.2”

错误的请找堆栈跟踪发生如下:

堆栈跟踪:

Got JS Exception: SyntaxError: Unexpected token ':'. Parse error. (index.android.bundle:1) 

java.lang.RuntimeException: com.facebook.react.devsupport.JSException: SyntaxError: Unexpected token ':'. Parse error. (index.android.bundle:1) 
                   at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:24) 
                   at com.facebook.react.devsupport.DisabledDevSupportManager.handleException(DisabledDevSupportManager.java:156) 
                   at com.facebook.react.cxxbridge.CatalystInstanceImpl.onNativeException(CatalystInstanceImpl.java:481) 
                   at com.facebook.react.cxxbridge.CatalystInstanceImpl.access$700(CatalystInstanceImpl.java:51) 
                   at com.facebook.react.cxxbridge.CatalystInstanceImpl$NativeExceptionHandler.handleException(CatalystInstanceImpl.java:497) 
                   at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:33) 
                   at android.os.Looper.loop(Looper.java:135) 
                   at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:208) 
                   at java.lang.Thread.run(Thread.java:818) 
                  Caused by: com.facebook.react.devsupport.JSException: SyntaxError: Unexpected token ':'. Parse error. (index.android.bundle:1) 
                   at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
                   at android.os.Handler.handleCallback(Handler.java:739) 
                   at android.os.Handler.dispatchMessage(Handler.java:95) 
                   at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) 
                   at android.os.Looper.loop(Looper.java:135)  
                   at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:208)  
                   at java.lang.Thread.run(Thread.java:818)  
                  Caused by: com.facebook.jni.CppException: SyntaxError: Unexpected token ':'. Parse error. (index.android.bundle:1) 
                   at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)  
                   at android.os.Handler.handleCallback(Handler.java:739)  
                   at android.os.Handler.dispatchMessage(Handler.java:95)  
                   at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)  
                   at android.os.Looper.loop(Looper.java:135)  
                   at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:208)  
                   at java.lang.Thread.run(Thread.java:818)  

index.android.bundle:

{"from":"/Users/Workspace/react-native-app/node_modules/react-native/Libraries/react-native/React.js","to":"react/lib/React","message":"Unable to resolve module `react/lib/React` from `/Users/Workspace/react-native-app/node_modules/react-native/Libraries/react-native/React.js`: Module does not exist in the module map or in these directories:\n /Users/Workspace/react-native-app/node_modules/react-native/node_modules/react/lib\n, /Users/Workspace/react-native-app/node_modules/react/lib\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n 1. Clear watchman watches: `watchman watch-del-all`.\n 2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.\n 3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.","name":"UnableToResolveError","type":"UnableToResolveError","errors":[{}]} 

的package.json

{ 
    "name": "Sample", 
    "version": "1.0.0", 
    "description": "Sample", 
    "main": "index.js", 
    "engines": { 
    "node": ">=4.3" 
    }, 
    "scripts": { 
    "build": "(cd android/ && ./gradlew assembleDebug)", 
    "start": "node node_modules/react-native/local-cli/cli.js start", 
    "build-ios": "node node_modules/react-native/local-cli/cli.js bundle -- 
entry-file index.ios.js --bundle-output iOS/main.jsbundle --platform 
\"ios\" --assets-dest ./ --dev false --reset-cache", 
"build-android": "node node_modules/react-native/local-cli/cli.js 
bundle --entry-file index.android.js --bundle-output iOS/main.jsbundle 
--platform \"android\" --assets-dest ./ --dev false --reset-cache", 
"ios": "node node_modules/react-native/local-cli/cli.js run-ios", 
"android": "node node_modules/react-native/local-cli/cli.js run- 
android" 
    }, 
    "dependencies": { 
    "clevertap-react-native": "~0.1.2", 
    "immutable": "~3.8.1", 
    "react": "~16.0.0-alpha.6", 
    "react-native": "~0.44.2", 
    "react-native-code-push": "^2.0.3-beta", 
    "react-native-collapsible": "~0.7.0", 
    "react-native-fbsdk": "~0.4.0", 
    "react-native-google-signin": "~0.8.1", 
    "react-native-htmlview": "~0.5.0", 
    "react-native-icon-badge": "~1.1.1", 
    "react-native-icon-checkbox": "~1.2.0", 
    "react-native-keyboard-aware-scroll-view": "~0.2.1", 
    "react-native-message-bar": "~1.6.0", 
    "react-native-modal-dropdown": "~0.4.0", 
    "react-native-navigation-redux-helpers": "~0.4.1", 
    "react-native-popup-dialog": "~0.3.15", 
    "react-native-radio-buttons": "~0.13.0", 
    "react-native-simple-gesture": "0.0.2", 
    "react-native-snackbar": "~0.2.0", 
    "react-native-textinput-effects": "~0.1.3", 
    "react-native-vector-icons": "~2.1.0", 
    "react-native-viewpager": "~0.2.12", 
    "react-redux": "~4.4.5", 
    "redux": "~3.5.2", 
    "redux-immutable": "~3.0.6", 
    "redux-saga": "~0.9.5", 
    "reselect": "~2.4.0", 
    "underscore": "~1.8.3" 
    }, 
    "devDependencies": { 
    "babel-eslint": "~6.0.2", 
    "babel-polyfill": "~6.7.4", 
    "eslint": "~2.8.0", 
    "eslint-loader": "~1.3.0", 
    "eslint-plugin-react": "~4.3.0", 
    "remote-redux-devtools": "~0.1.6" 
} 
} 

回答

0

试试下面的方法

从你的反应本地文件夹中运行:

cd android && gradlew clean 

THEN

cd .. && react-native run-android 

注:

为Mac,你可能需要改变gradlew到./gradlew

你能张贴您的package.json依赖

+0

试过,但没有运气 –

+0

你可以发布你的package.json依赖 – Arunkumar