简体   繁体   English

由于 webpack 无法构建反应项目

[英]can not build react project due to webpack

I am bumping in a annoying issue.我遇到了一个烦人的问题。 I am trying to buişd a project using web3 upon other things and I get some compilation error I can not sort out:我正在尝试在其他事情上使用 web3 构建一个项目,但我遇到了一些我无法解决的编译错误:

Compiled with problems: X

ERROR in ../node_modules/cipher-base/index.js 3:16-43

Module not found: Error: Can't resolve 'stream' in 'C:\CAS\node_modules\cipher-base'

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: { "stream": require.resolve("stream-browserify") }'
    - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "stream": false }

I tried lots of things but can not manage to get it work out.我尝试了很多东西,但无法成功。 Can someone help?有人可以帮忙吗?

I managed to get it o work我设法让它工作

adding at the root of the website: webpack.config在网站根目录添加:webpack.config

containing:包含:

    module.exports = {
resolve: {
    fallback: {
        assert: require.resolve('assert'),
        crypto: require.resolve('crypto-browserify'),
        http: require.resolve('stream-http'),
        https: require.resolve('https-browserify'),
        os: require.resolve('os-browserify/browser'),
        stream: require.resolve('stream-browserify'),
    },
},
// Webpack 5 is enabled by default
// You can still use webpack 4 while upgrading to the latest version of Next.js by adding the "webpack5: false" flag
webpack5: false,

}; };

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

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