Screenshot for Error: Can't resolve 'process/browser':

I'm hoping someone could help me here. With the Webpack 5 breaking changes with polyfills I was able to use react-rewired to add fallbacks to a config-overrides.js
I npm installed every dependency I could, but I'm still getting this error for "process/browser". I'm not really sure how to identify the problem.
const webpack = require("webpack");
module.exports = function override(config) {
const fallback = config.resolve.fallback || {};
Object.assign(fallback, {
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("stream-browserify"),
assert: require.resolve("assert"),
http: require.resolve("stream-http"),
https: require.resolve("https-browserify"),
os: require.resolve("os-browserify"),
url: require.resolve("url"),
zlib: require.resolve("browserify-zlib"),
fs: require.resolve("browserify-fs"),
process: require.resolve("process"),
buffer: require.resolve("buffer"),
net: require.resolve("net"),
});
config.resolve.fallback = fallback;
config.plugins = (config.plugins || []).concat([
new webpack.ProvidePlugin({
process: "process/browser",
Buffer: ["buffer", "Buffer"],
}),
]);
return config;
};
I was having the exact same problem, and eventually found this https://github.com/react-dnd/react-dnd/issues/3425#issuecomment-1214554950.
I added 'process/browser': require.resolve('process/browser') to the fallbacks object without changing anything else and it worked. Hopefully it fixes it for you too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With