繁体   English   中英

在 React 中导入 web3 时无法修复错误

[英]I can't fix error while importing web3 in React

我只想在 React 中导入 web3,但我总是看到如下错误(7 个错误),我已经安装了“crypto-browserify”、“stream-http”、“https-browserify”。 但它们不起作用! 如果您以前遇到过类似问题,请帮助我。

ERROR in ./node_modules/eth-lib/lib/bytes.js 9:193-227

Module not found: Error: Can't resolve 'crypto' in 'D:\4_learning\Blockchain\React-Solidity-Web3\blockchain\contacts\node_modules\eth-lib\lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
    - add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
    - install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "crypto": false }
...

这是create-react-app 和损坏的 webpack v5的问题。 有很多解决方法,但我只是使用较旧的反应,直到有一个好的反应。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM