我正在运行一个 Gatsby3 网站,和许多人一样,当我尝试使用某些 web3 插件时,我遇到了有关缺少 Polyfills 的 Webpack 5 错误。我知道他们不再自动执行这些操作,我必须自己处理它们。
在尝试了我能找到的所有解决方案之后,这个似乎应该可行,但不适合我。我猜我做错了什么/错过了什么。
这是我添加到 Gatsby 配置中的内容,用于处理“crypto”和“stream”缺少的 polyfill:
exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
resolve: {
fallback: {
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
},
},
})
}
Run Code Online (Sandbox Code Playgroud)
我确实安装了 crypto-browserify 和stream-browserify。
然而,同样的错误仍然存在:
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 …Run Code Online (Sandbox Code Playgroud)