node.js – TypeError: Cannot read properties of undefined (reading ‘getArguments’)

When I deploy the application on Heroku, I get the following error, already tried different versions of webpack, also installed and uninstalled but nothing helped:

    [webpack-cli] TypeError: Cannot read properties of undefined (reading 'getArguments')
at WebpackCLI.getBuiltInOptions (/tmp/build_cb26c8c0/node_modules/webpack-cli/lib/webpack-cli.js:755:63)
at makeCommand.options.entry (/tmp/build_cb26c8c0/node_modules/webpack-cli/lib/webpack-cli.js:880:32)
at async WebpackCLI.makeCommand (/tmp/build_cb26c8c0/node_modules/webpack-cli/lib/webpack-cli.js:395:31)
at async loadCommandByName (/tmp/build_cb26c8c0/node_modules/webpack-cli/lib/webpack-cli.js:876:17)
at async Command.<anonymous> (/tmp/build_cb26c8c0/node_modules/webpack-cli/lib/webpack-cli.js:1272:17)
at async Command.parseAsync (/tmp/build_cb26c8c0/node_modules/webpack-cli/node_modules/commander/lib/command.js:916:5)
at async WebpackCLI.run (/tmp/build_cb26c8c0/node_modules/webpack-cli/lib/webpack-cli.js:1296:9)
at async runCLI (/tmp/build_cb26c8c0/node_modules/webpack-cli/lib/bootstrap.js:9:9)

my package.json file:

{
  "dependencies": {
    "@babel/preset-react": "^7.18.6",
    "@rails/webpacker": "^5.4.3",
    "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
    "html-webpack-plugin": "^5.5.0",
    "i18n-js": "^4.2.0",
    "path": "^0.12.7",
    "prop-types": "^15.8.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-loader": "^9.1.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "webpack": "^5.75.0",
    "webpack-cli": "^5.0.1",
    "webpack-dev-server": "^4.11.1"
  }

Read more here: Source link