I have installed webpack 4.5.0.
When I try to run webpack, it complains that it wants webpack-cli.
If I run npm install webpack-cli
I get the following error:
The CLI moved into a separate package: webpack-cli
Would you like to install webpack-cli? (That will run npm install -D webpack-cli) (yes/NO)yes
npm WARN deprecated [email protected]: Package no longer supported. Contact [email protected] for more info.
npm WARN [email protected] requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
+ [email protected]
updated 1 package in 14.175s
{ Error: Cannot find module 'webpack-cli'
at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:470:25)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at runCommand.then.result (/usr/local/lib/node_modules/webpack/bin/webpack.js:62:14)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:118:7) code: 'MODULE_NOT_FOUND' }
Anybody has seen this and fixed it somehow?
webpack CLI provides a flexible set of commands for developers to increase speed when setting up a custom webpack project. As of webpack v4, webpack is not expecting a configuration file, but often developers want to create a more custom webpack configuration based on their use-cases and needs.
If you're using webpack v4 or later and want to call webpack from the command line, you'll also need to install the CLI.
This is happening because while webpack-cli
might be installed globally, it is not installed in your current project, and somehow the project isn't capable of using the globally-installed version.
I fixed this by running npm install webpack-cli
in the relevant project directory.
It worked for me by installing below modules:
npm i -g webpack-cli
npm install --save-dev webpack
npm install --save-dev webpack-dev-server
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