My Intial Problem was that webpack 5 doesnt have polyfills so I had to find a way to solve that.
I used the second solution on this link to solve that problem: i tried to Polyfill modules in webpack 5 but not working (Reactjs)
I did:
npm install react-app-rewired
and I changed the package.json start script to:
'start': 'react-app-rewired start'
then I created the config.overide.js file:
module.exports = function override (config, env) {
console.log('override');
let loaders = config.resolve;
loaders.fallback = {
"crypto": require.resolve("crypto-browserify"),
"path": require.resolve("path-browserify"),
"stream": require.resolve("stream-browserify"),
"http": require.resolve("stream-http"),
"util": require.resolve("util"),
"querystring": require.resolve("querystring-es3"),
"url": require.resolve("url/"),
"fs": false,
};
return config;};
This solved my polyfill errors but now i am getting this error:
Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')
at Object../node_modules/express/lib/response.js (response.js:42:1)
at Object.options.factory (react refresh:6:1)
at __webpack_require__ (bootstrap:24:1)
at fn (hot module replacement:61:1)
at Module../src/screens/LoginScreen.js (HomeScreen.js:46:1)
at Module.options.factory (react refresh:6:1)
at __webpack_require__ (bootstrap:24:1)
at fn (hot module replacement:61:1)
at Module../src/App.js (bundle.js:24:78)
at Module.options.factory (react refresh:6:1)
I have a feeling that this error is comming from me trying to overide webpack. my github: https://github.com/ilanhk/MERN-Ecommerce-Template