Zack
Zack

Reputation: 91

Webpack Peer Dependency Error in NPM When Webpack Is Installed

I'm getting this error when running webpack-dev-server in npm:

[email protected] requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.

However, I already installed webpack. Here is my package.json. What am I missing?

{
  ...
  "scripts": {
    "watch": "webpack-dev-server --progress --https"
  },
  ...
  "devDependencies": {
    "webpack": "^5.4.0",
    "webpack-cli": "^4.2.0",
    "webpack-dev-server": "^3.11.0"
  }
}

Upvotes: 1

Views: 8419

Answers (1)

Trott
Trott

Reputation: 70075

You have webpack@5 installed but the peer dependency warning is asking for webpack@4. There is a bug filed in the webpack-dev-server issue tracker about the incompatibility with webpack@5. As of a few days ago, they're working on it.

So one option is to be patient and watch that issue. When a version compatible webpack@5 is released, upgrade to it.

Another option is to downgrade your current project to webpack@4. I don't know how big the breaking changes between webpack@4 and webpack@5 are, but it's an option to try. Given that [email protected] was released only a month ago, this may be an OK option. The latest version of [email protected] is [email protected] and (as of this writing) is only 2 months old.

Upvotes: 2

Related Questions