如何将eth-lightwallet包导入react-native项目?

时间:2018-08-03 06:33:53

标签: android react-native ethereum web3

首先,我创建了一个项目:react-native init project,然后 当我尝试在我的本机项目中import * as lightwallet from 'eth-lightwallet'时,出现错误see this image

找到了解决方法at github,但这并不能解决我的问题。

我的package.json:

{
  "name": "androidWallet",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "asn1": "^0.2.3",
    "buffer": "^5.2.0",
    "eth-lightwallet": "^3.0.1",
    "history": "^4.7.2",
    "native-base": "^2.7.2",
    "node-libs-browser": "^2.1.0",
    "node-libs-react-native": "^1.0.2",
    "react": "16.4.1",
    "react-native": "0.55.2",
    "react-native-table-component": "^1.1.8",
    "react-navigation": "^2.9.3",
    "react-redux": "^5.0.7",
    "react-router-dom": "^4.3.1",
    "react-router-redux": "^4.0.8",
    "redux": "^4.0.0",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.3.0",
    "web3": "^0.20.6"
  },
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-jest": "23.4.2",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react-native": "4",
    "jest": "23.4.2",
    "react-test-renderer": "16.4.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

1 个答案:

答案 0 :(得分:0)

问题在于eth-lightwallet依赖于React Native不支持的节点核心模块。当前的解决方法涉及使用 rn-nodeify是为了提供垫片供React Native使用。请参阅this issue for react nativethis open issue from eth-lightwallet