57

'Github' asked me to update 'webpack-dev-server' to version 3.1.11 or higher for security reasons.

However, 'npm run dev' will not run after the update.

I don't solve this problem

Error: Cannot find module 'webpack-cli/bin/config-yargs'

The code for 'package.json' is as follows.

 "dependencies": { "@vue/cli-plugin-babel": "^3.5.1", "config": "^3.0.1", "vue": "^2.5.2", "vue-router": "^3.0.1" }, "devDependencies": { "vue-jest": "^1.0.2", "vue-loader": "^13.3.0", "vue-style-loader": "^3.0.1", "vue-template-compiler": "^2.5.2", "webpack": "^3.12.0", "webpack-bundle-analyzer": "^3.3.2", "webpack-cli": "^3.3.10", "webpack-dev-server": "^3.1.14", "webpack-merge": "^4.1.0" }, "engines": { "node": ">= 6.0.0", "npm": ">= 3.0.0" }, "browserslist": [ "> 1%", "last 2 versions", "not ie <= 8" ] 
6
  • 1
    Please excuse me for not putting all the codes because "It looks like your post is mostly code; please add some more details." Commented Jan 6, 2020 at 11:50
  • Which was your previous webpack-dev-server version? Commented Jan 6, 2020 at 12:04
  • Also how did you update the version? Commented Jan 6, 2020 at 12:12
  • It was 2.11.5. And what is the updated version? webpack-dev-server update? Commented Jan 6, 2020 at 12:25
  • 2.x.x -> 3.x.x is a major version update, so it may not be compatible with the rest of your dependencies. I suggest to review the vulnerability report and in case it's something minor or improbable to revert the update. Commented Jan 6, 2020 at 15:12

11 Answers 11

170

You could try changing webpack-dev-server to webpack serve in your npm run script inside package.json

Sign up to request clarification or add additional context in comments.

9 Comments

This is a useful answer particular when your project has these versions webpack": "^5.2.0 webpack-cli": "^4.1.0 webpack-dev-server": "^3.11.0
I had the same issue and I coudnt find a way to solve it... but, this is the perfect answer... and as @Mark said... Works perfect for the versions he mentioned above... Thank you.
This answer saved me! THANKS.
I got above error message with rails 6 and yarn. My package.json doesn't have a script command inside. Do you @Gakis41 may know how to handle this?
@Phipsen can you share your package.json? Do you have webpack & webpack-cli installed in devDependencies?
|
35

For some reason the webpack team changed the command to webpack serve Change your package.json:

"start": "webpack serve"

Ref: https://github.com/webpack/webpack-dev-server/issues/2759

The version I am using:

"webpack": "^5.10.0", "webpack-cli": "^4.2.0", "webpack-dev-server": "^3.11.0" 

Comments

21

To fix it just do 2 things.

  1. Install npm i webpack-cli @webpack-cli/init
  2. Add this to your package.json:
    "scripts": { "start": "webpack-cli serve --mode development" }, 

Done!

1 Comment

Thanks for help, I follow all things and many blogs but this work for me. Please add some expansion.
20

I agree that you have to upgrade from webpack 3 to 4, but specifically these are the steps I had to do, first, because webpack-cli has been split out into a separate package:

$ npm install webpack webpack-cli --save-dev 

As explained here: https://webpack.js.org/guides/getting-started/#basic-setup

Comments

17

Delete package-lock.json file. Change following in package.json.

"webpack": "^4.32.2", "webpack-cli": "^3.3.0", "webpack-dev-server": "^3.11.0" 

Run npm install

Comments

16

Change webpack-dev-server to webpack serve in package.json file.

e.g.:

"scripts": { "start": "webpack serve --mode development --open" },

It worked for me! ;-)

Comments

5
"scripts": { "start": "webpack serve --mode development", "build": "webpack --mode production" }, 

Run: npm run start or npm start now

Comments

3

It is because of version of webpack-cli. In some versions, there is no config-yargs.js file. So ^3.3.11 version of webpack-cli worked for me. Try it:

npm i webpack-cli@^3.3.11

Comments

1

webpack core team says that form version 3+ the compatibility will foucs on webpack 4

so I think you need also to update webpack 3 to webpack 4

this doc may help you to achieve that https://webpack.js.org/migrate/4

1 Comment

I already solve this problem, but thanks for your attention.
0

You have to check to find out the latest versions of webpack, webpack-cli and webpack-dev-server and when you have that information edit package.json to reflect those versions and run yarn install --check-files Then you'll have to start the webpack-dev-server with the command "npx webpack serve"

Comments

0

Try changing the package.json file line : [email protected]

Then run below commands in terminal: It has worked for me.

  1. npm install [email protected]
  2. npm install --save-dev webpack-cl

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.