首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JSON解析错误:意外的标识符"RCTWebSocketModule“

JSON解析错误:意外的标识符"RCTWebSocketModule“
EN

Stack Overflow用户
提问于 2016-10-04 15:39:03
回答 3查看 1.7K关注 0票数 1

我已经升级了react和react-native依赖项。当我试图在一个真实的设备上构建和运行我的原生react应用程序时,我在xcode中得到了以下堆栈跟踪,并且在启动后应用程序在白屏上冻结。

代码语言:javascript
复制
2016-10-04 12:33:37.501 [info][tid:main][RCTBatchedBridge.m:74]   Initializing <RCTBatchedBridge: 0x16575a10> (parent: <RCTBridge:   0x1658e200>, executor: RCTJSCExecutor)
2016-10-04 12:33:37.507136 ReactApp[237:7244] Initializing <RCTBatchedBridge: 0x16575a10> (parent: <RCTBridge: 0x1658e200>, executor: RCTJSCExecutor)
2016-10-04 12:33:37.695956 ReactApp[237:7292] [] __nw_connection_get_connected_socket_block_invoke 1 Connection has no connected handler
2016-10-04 12:33:37.780 [info][tid:main][RCTBatchedBridge.m:74] Initializing <RCTBatchedBridge: 0x16681ec0> (parent: <RCTBridge: 0x1658e200>, executor: RCTWebSocketExecutor)
2016-10-04 12:33:37.780715 ReactApp[237:7244] Initializing <RCTBatchedBridge: 0x16681ec0> (parent: <RCTBridge: 0x1658e200>, executor: RCTWebSocketExecutor)
2016-10-04 12:33:37.865 [warn][tid:com.facebook.react.RCTBridgeQueue][RCTModuleData.mm:287] Required dispatch_sync to load constants for RCTUIManager. This may lead to deadlocks
2016-10-04 12:33:37.866815 ReactApp[237:7292] Required dispatch_sync to load constants for RCTUIManager. This may lead to deadlocks
2016-10-04 12:33:38.274 [error][tid:com.facebook.react.JavaScript] JSON Parse error: Unexpected identifier "RCTWebSocketModule"
2016-10-04 12:33:38.274231 ReactApp[237:7303] JSON Parse error: Unexpected identifier "RCTWebSocketModule"
2016-10-04 12:33:38.281 [info][tid:com.facebook.react.JavaScript] 'Failed to print error: ', 'JSON Parse error: Unexpected identifier "RCTSourceCode"'
2016-10-04 12:33:38.281396 ReactApp[237:7303] 'Failed to print error: ', 'JSON Parse error: Unexpected identifier "RCTSourceCode"'
2016-10-04 12:33:38.286 [error][tid:com.facebook.react.JavaScript] Requiring module "185", which threw an exception.
2016-10-04 12:33:38.286470 ReactApp[237:7303] Requiring module "185", which threw an exception.
2016-10-04 12:33:38.287 [info][tid:com.facebook.react.JavaScript] 'Failed to print error: ', 'Requiring module "191", which threw an exception.'
2016-10-04 12:33:38.286985 ReactApp[237:7303] 'Failed to print error: ', 'Requiring module "191", which threw an exception.'

当我在android studio中运行相同的项目时,我得到了以下堆栈跟踪:

代码语言:javascript
复制
E/ReactNativeJS: JSON Parse error: Unexpected identifier "UIManager"
I/ReactNativeJS: 'Failed to print error: ', 'JSON Parse error: Unexpected identifier "SourceCode"'
W/unknown:React: Packager connection already open, nooping.
E/ReactNativeJS: Module AppRegistry is not a registered callable module.
E/ReactNativeJS: Requiring module "173", which threw an exception.
I/ReactNativeJS: 'Failed to print error: ', 'Requiring module "173", which threw an exception.'
I/ReactNativeJS: 'Failed to print error: ', 'JSON Parse error: Unexpected identifier "ExceptionsManager"'

Package.json

代码语言:javascript
复制
{
  "dependencies": {
    "react": "15.3.2",
    "react-dom": "15.3.2",
    "react-native": "^0.34.1",
    "react-native-animatable": "0.6.1",
    "react-native-collapsible": "0.7.0",
    "react-native-drawer": "2.2.6",
    "react-native-htmlview": "^0.5.0",
    "react-native-push-notification": "^2.1.1",
    "react-native-viewpager": "0.2.11",
    "react-redux": "4.4.5",
    "redux": "3.5.2",
    "redux-thunk": "2.1.0"
  }
}
EN

回答 3

Stack Overflow用户

发布于 2016-10-06 15:24:01

我今晚遇到了这个。这对我来说是一个缓存问题。重新启动React Native Packager。

票数 1
EN

Stack Overflow用户

发布于 2016-10-04 15:54:36

package.json无效。下面是来自json-validator的响应:

Error: Parse error on line 1: "dependencies": { "react": "1 --------------^ Expecting 'EOF', '}', ',', ']', got ':'

它必须看起来像这样:

{ "dependencies": { "react": "15.3.2", "react-dom": "15.3.2", "react-native": "^0.34.1", "react-native-animatable": "0.6.1", "react-native-collapsible": "0.7.0", "react-native-drawer": "2.2.6", "react-native-htmlview": "^0.5.0", "react-native-push-notification": "^2.1.1", "react-native-viewpager": "0.2.11", "react-redux": "4.4.5", "redux": "3.5.2", "redux-thunk": "2.1.0" } }

票数 0
EN

Stack Overflow用户

发布于 2016-10-24 17:11:36

在与现有应用程序集成时,我也遇到了同样的问题。我解决了。我在package.json中的"react-native“版本代码与安卓应用的不同,我使用npm安装了相同的版本。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39846740

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档