React-Native导入Realm会导致错误

时间:2016-09-08 21:06:10

标签: react-native realm

我正在尝试使用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。

0 个答案:

没有答案