我使用 Webpack 5 创建了一个新的 React 项目,npx create-react-app client并遇到了一些问题。最初,我在 、 和 方面遇到了错误assert,os但stream通过安装它们并将它们包含在webpack.config.js. 该文件位于client/src文件夹中。
错误如下所示:
Compiled with problems:
ERROR in ./node_modules/eth-lib/lib/bytes.js 9:193-227
Module not found: Error: Can't resolve 'crypto' in 'C:\Users\Username\Projects\testProject\client\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 …Run Code Online (Sandbox Code Playgroud) 我不明白为什么......这是 GitHub 存储库:https : //github.com/Dronrom/React-test