I am working on ReactJS application and configured "webpack": "^2.7.0"
,
"webpack-cli": "^2.0.9
" but while running the webpack from cmd it has the following error.
const statsPresetToOptions = require("webpack").Stats.presetToOptions;
^
TypeError: Cannot read property 'presetToOptions' of undefined
at processOptions (F:\reactJs_weather\React-Weather-App\node_modules\webpack-cli\bin\webpack.js:284:57)
Do you have any idea?
webpack-cli
needs at least webpack
version 4 to run.
If you're using older version like webpack 2 or 3, you don't need to add webpack-cli
package seperately. It comes already built in with older versions of webpack
itself.
From version 4, the entire CLI has been ported inside a separate package webpack-cli
.
The fix should be to remove webpack-cli
package or use latest version of webpack>=4
.
There's an ongoing PR about adding webpack 4 as peer dependency, so soon there would a warning popping up about the same.
Related discussions: webpack is not listed as a peer, add webpack 4 as peer dependency
I was also facing issue and resolve using below steps:
npm uninstall webpack-cli
"build": "webpack --config build/webpack.conf.js --color"
for build in package.json instead of webpack-clihope it will help.
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