I currently try to upgrade my react-scripts from 4 > 5 (5.0.1). I was facing issues related to react-scripts (as many other did) not providing polyfills and therefore was following this Guide to provide those.
My config-overides.js (as described in the Guide) looks like this:
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"),
"buffer": require.resolve("buffer"),
"path": require.resolve("path"),
"process/browser": require.resolve("process/browser"),
"querystring": require.resolve("querystring-es3"),
"zlib": require.resolve('browserify-zlib'),
"vm": require.resolve("vm-browserify"),
"async_hooks": require.resolve("async-hooks"),
"fs": false,
"net": false,
"express": require.resolve("express")
})
config.resolve.fallback = fallback;
config.plugins = (config.plugins || []).concat([
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer']
})
])
return config; }
and im using react 18.2.0 and express 4.19.2.
Now when I want to run the application (npm start) I am facing this error:
Cannot read properties of undefined (reading 'prototype')
TypeError: Cannot read properties of undefined (reading 'prototype')
at ./node_modules/express/lib/response.js (http://localhost:3000/static/js/bundle.js:105067:45)
at options.factory (http://localhost:3000/static/js/bundle.js:247856:31)
at __webpack_require__ (http://localhost:3000/static/js/bundle.js:247255:32)
at fn (http://localhost:3000/static/js/bundle.js:247514:21)
at ./node_modules/express/lib/express.js (http://localhost:3000/static/js/bundle.js:104335:11)
at options.factory (http://localhost:3000/static/js/bundle.js:247856:31)
at __webpack_require__ (http://localhost:3000/static/js/bundle.js:247255:32)
at fn (http://localhost:3000/static/js/bundle.js:247514:21)
at ./node_modules/express/index.js (http://localhost:3000/static/js/bundle.js:103672:18)
at options.factory (http://localhost:3000/static/js/bundle.js:247856:31)
at __webpack_require__ (http://localhost:3000/static/js/bundle.js:247255:32)
at fn (http://localhost:3000/static/js/bundle.js:247514:21)
at ./src/components/Tool/ModuleOverview/CommonComponents/Actions/Administration/CompanyAdministration/CompanyAdministration.js (http://localhost:3000/static/js/bundle.js:4132:65)
at options.factory (http://localhost:3000/static/js/bundle.js:247856:31)
at __webpack_require__ (http://localhost:3000/static/js/bundle.js:247255:32)
at fn (http://localhost:3000/static/js/bundle.js:247514:21)
As the error suggest, there seems to be something wrong with express (at ./node_modules/express/lib/response.js
).
I already tried to change the variable declaration from var to let in the response.js as described here aswell changing "express": require.resolve("express")
to "express": false
. However this did not change anything.
I appreciate any suggestions or help. Thanks in advance.