I’m working on a project that uses ‘webpack’. After pulling in a code update that required developers to clear out node_modules and update yarn, I started receiving the following prompt when running webpack:
The CLI moved to a separate package: webpack-cli
Would you like to install webpack-cli? (That will run yarn add -D webpack-cli) (yes/NO)
(I found running this – even manually running the yarn command – didn’t actually install the CLI and in fact, produced further errors).
Even trying to return the webpack version raised the prompt:
The problem, I have been told, is the version of webpack being loaded with “npm install -g webpack” was higher than the version we actually wanted and included ‘webpack-cli’ being split into a separate package. Specifically, we want to work with version 3.8.1.
You can see in the screenshots above just running “npm install -g webpack” installs version 3.8.3 (incidentally I cannot find a reference to version 3.8.3 on the NPM webpack page or webpack’s GitHub releases page).
1) Delete the ‘npm’ and ‘npm-cache’ folder from your user profile Roaming AppData folder (i.e. from the Windows “Run” prompt run %AppData%).
2) Install the specific webpack version. i.e. npm install -g firstname.lastname@example.org
Now you can run ‘webpack’ as expected.