I am using a config-overrides.js file that looks like:
/* config-overrides.js */
const path = require("path");
const webpack = require("webpack");
module.exports = function override(config, env) {
console.log("React app rewired works!");
// // Add webpack aliases for Node.js modules
// config.resolve.alias = {
// ...config.resolve.alias,
// // Add alias for the process module to use a browser-compatible version
// "process": "process/browser",
// // Add more aliases as needed
// };
config.plugins.push(
new webpack.ProvidePlugin({
process: "process/browser",
})
);
// Set fallbacks for other Node.js modules
config.resolve.fallback = {
assert: require.resolve("assert/"),
stream: require.resolve("stream-browserify"),
crypto: require.resolve("crypto-browserify"),
url: require.resolve("url/"),
querystring: require.resolve("querystring-es3"),
os: require.resolve("os-browserify/browser"),
zlib: require.resolve("browserify-zlib"),
https: require.resolve("https-browserify"),
path: require.resolve("path-browserify"),
http: require.resolve("stream-http"),
vm: require.resolve("vm-browserify"),
net: require.resolve("net-browserify"),
tls: require.resolve("tls-browserify"),
fs: false,
async_hooks: false,
};
return config;
};
package.json:
{
"name": "razorpay_integration",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"assert": "^2.1.0",
"browserify-zlib": "^0.2.0",
"config": "^3.3.11",
"crypto-browserify": "^3.12.0",
"fs": "^0.0.1-security",
"https-browserify": "^1.0.0",
"net-browserify": "^0.2.4",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
"querystring-es3": "^0.2.1",
"razorpay": "^2.9.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"tls-browserify": "^0.2.2",
"url": "^0.11.3",
"vm-browserify": "^1.1.2",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"copy-webpack-plugin": "^12.0.2",
"customize-cra": "^1.0.0",
"dotenv": "^16.4.5",
"node-polyfill-webpack-plugin": "^3.0.0",
"react-app-rewired": "^2.2.1",
"webpack": "^5.90.3",
"webpack-cli": "^5.1.4"
},
"browser": {
"fs": false
}
}
error:
Uncaught runtime errors: × 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:51923:45) at options.factory (http://localhost:3000/static/js/bundle.js:167736:31) at webpack_require (http://localhost:3000/static/js/bundle.js:167165:32) at fn (http://localhost:3000/static/js/bundle.js:167394:21) at ./node_modules/express/lib/express.js (http://localhost:3000/static/js/bundle.js:51191:11) at options.factory (http://localhost:3000/static/js/bundle.js:167736:31) at webpack_require (http://localhost:3000/static/js/bundle.js:167165:32) at fn (http://localhost:3000/static/js/bundle.js:167394:21) at ./node_modules/express/index.js (http://localhost:3000/static/js/bundle.js:50528:18) at options.factory (http://localhost:3000/static/js/bundle.js:167736:31) at webpack_require (http://localhost:3000/static/js/bundle.js:167165:32) at fn (http://localhost:3000/static/js/bundle.js:167394:21) at ./node_modules/net-browserify/api.js (http://localhost:3000/static/js/bundle.js:72560:15) at options.factory (http://localhost:3000/static/js/bundle.js:167736:31) at webpack_require (http://localhost:3000/static/js/bundle.js:167165:32) at fn (http://localhost:3000/static/js/bundle.js:167394:21) at ./node_modules/request-promise/node_modules/tough-cookie/lib/cookie.js (http://localhost:3000/static/js/bundle.js:127051:11) at options.factory (http://localhost:3000/static/js/bundle.js:167736:31) at webpack_require (http://localhost:3000/static/js/bundle.js:167165:32) at fn (http://localhost:3000/static/js/bundle.js:167394:21) at http://localhost:3000/static/js/bundle.js:126979:5 at module.exports (http://localhost:3000/static/js/bundle.js:143656:5)