我正在尝试使用react-native和realm开发应用程序。但是一旦我尝试在任何组件中导入Realm,我就会遇到以下两个错误:
ExceptionsManager.js:61Cannot read property 'debugHosts' of undefined
handleException @ ExceptionsManager.js:61
handleError @ InitializeJavaScriptAppEngine.js:115
reportFatalError @ error-guard.js:30
guardedLoadModule @ require.js:60
_require @ require.js:49
(anonymous function) @ require-0.js:1
executeApplicationScript @ debuggerWorker.js:18
onmessage @ debuggerWorker.js:33
ExceptionsManager.js:61Module AppRegistry is not a registered callable module.
handleException @ ExceptionsManager.js:61
handleError @ InitializeJavaScriptAppEngine.js:115
reportFatalError @ error-guard.js:30
guard @ MessageQueue.js:43
callFunctionReturnFlushedQueue @ MessageQueue.js:94
onmessage @ debuggerWorker.js:39
一切正常,直到我尝试导入Realm(import Realm from 'realm';
)。
package.json
中添加了它。 npm install
一起安装,并将其与rnpm link realm
相关联。 var Realm = require('realm')
导入它。同样的错误package.json中的依赖项:
"dependencies": {
"flux": "^2.1.1",
"react": "15.2.1",
"react-native": "0.31.0",
"react-native-action-button": "^1.1.11",
"react-native-radio-buttons": "^0.12.1",
"react-native-router-flux": "^3.35.0",
"react-redux": "^4.4.5",
"realm": "^0.14.3",
"redux": "^3.5.2"
},
我正在使用VS Code和React Native Tools以及Genymotion。