webpack-dev-server startup error

Today, I start webpack-dev-server on my Visual Studio’s terminal as usual like this:

webpack-dev-server --open --port 3000 --contentBase src --hot

However I got an error:

internal/modules/cjs/loader.js:969
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'

As the error message shows that something wrong with my webpack-cli dependency. I realized that I had upgraded my webpack-cli which is dependent on webpack-dev-server.

We can see that webpack-dev-server makes it clear in its source code.

Fixing this issue is simple:

Step 1: Uninstall the webpack-cli

 npm uninstall webpack-cli 

Step 2: Install webpack-cli version 3

npm install webpack-cli [email protected] -S

Now everything works well for me.

RSS