我正在用 React Native 构建一个以太坊 ERC20 代币支持钱包,过去几天我一直在为这个特殊问题苦苦挣扎,我希望有人能提供帮助。
The package at "node_modules/web3-eth-accounts/src/index.js" attempted to import the Node standard library module "crypto"
这是我的 package.json 文件。
"dependencies": {
"expo": "^33.0.0",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
"react-native-web": "^0.11.4",
"socket.io-client": "^2.2.0",
"web3": "1.0.0-beta.34",
"cryptico": "^1.0.2",
"native-base": "2.8.0",
"node-libs-browser": "2.1.0",
"react-native-crypto": "^2.0.0",
"react-native-randombytes": "^2.0.0"
},
"devDependencies": {
"babel-preset-expo": "^5.1.1",
"babel-cli": "6.26.0",
"babel-preset-es2015": "6.24.1"
},
请指教! 我也关注了这个链接,没有运气! https://gist.github.com/dougbacelar/29e60920d8fa1982535247563eb63766
最佳答案
我有 2 个答案给你:)
1) 使用 ethers.js 因为它很丰富并且默认支持 React Native
2) 从您提供给项目的链接复制垫片并将其导入顶部的 App.js 文件,这样您的 web3 库就可以工作了
关于react-native - 位于 "node_modules/web3-eth-accounts/src/index.js"的包试图导入 Node 标准库模块 "crypto",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57015563/