DEV Community

loading...
Cover image for [webpack-cli] "Would you like to install webpack-cli?(yes/NO)" crash to solve

[webpack-cli] "Would you like to install webpack-cli?(yes/NO)" crash to solve

arisa_dev
Developer Relations Engineer at Storyblok. Love Aikido🥋 A free tech knowledge-sharing community, Lilac organizer💪 A host of Anonymous.fm https://dev.to/anonymousfm-arisa
・2 min read

Hi there!

I'm Arisa, a freelance Full Stack Developer living in Germany🇩🇪

I'm developing Lilac, an online school with hands-on Frontend e-books and tutoring👩‍💻

What is this article about?

  • webpack-cli error

An error log is in here👇

Would you like to install webpack-cli? (That will run npm install -D webpack-cli) (yes/NO)
Enter fullscreen mode Exit fullscreen mode

If "yes"...

BAM

You'll see another pile of errors.

TypeError: Class constructor ServeCommand cannot be invoked without 'new' at runWhenInstalled
Enter fullscreen mode Exit fullscreen mode

If "NO"...

BAZINGA

Oh yes, he'll keep asking you forever the same questions.

Who is this article for?

  • Anyone who suffers from this bazinga🚨
  • Anyone has an old project with v3 webpack-cli

Which environment I had?

Seeing is faster than explaining, right?👍

  "dependencies": {
    "cors": "^2.8.4",
    "express": "^4.16.2",
    "mime": "^2.2.0",
    "whatwg-fetch": "^2.0.3"
  },
  "devDependencies": {
    "webpack": "^4.28.3",
    "webpack-cli": "^3.2.0",// 👈 He's your devil😈
    "webpack-dev-middleware": "^3.5.0",
    "webpack-dev-server": "^3.1.14",
    "webpack-hot-middleware": "^2.24.3"
  }
Enter fullscreen mode Exit fullscreen mode

How to get out from this error loop?

Just update your webpack-cli.

Minimum requires 4.3.0 from what people were crowding about this error.

webpack/webpack-cli repo issue: Error when run npm start: Class constructor ServeCommand cannot be invoked without 'new' #2272

In my case, I simply removed an old webpack-cli and got new.

$ yarn remove webpack-cli && yarn add --dev webpack-cli
Enter fullscreen mode Exit fullscreen mode
"webpack-cli": "^4.4.0"
Enter fullscreen mode Exit fullscreen mode

I know webpack updated to v5 last autumn. But I needed a compromised version to prevent getting another crash from other packages to test changing to webpack v5.

Mission accomplished👍

Discussion (1)

Collapse
keith_rowell_proper profile image
Keith Rowell

Thank you!

This could have been hours. Found you post and got out of that tar pit inside a minute. Creating an account at dev.to to post this "thank you" took longer.