'Javascript & Webpack: Error: Unknown option '--watch-content-base'

I am trying to integrate WebPack into the scripts my package.json file. I was following a video to try and do it and it works fine up until I enter 'npm start'.

I get an error message in the terminal reading:

[webpack-cli] Error: Unknown option '--watch-content-base'
[webpack-cli] Run 'webpack --help' to see available commands and options
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] start: `webpack-dev-server --watch-content-base --open`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

And I cannot understand why I'm getting this error considering in the video I was following it works just fine. If I remove ' --watch-content-base' it works but I'm trying to make sure any code changes are automatically updated on the server.

This is my package.json file:

{
  "name": "frontend",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "webpack-dev-server --watch-content-base --open",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^5.51.1",
    "webpack-cli": "^4.8.0",
    "webpack-dev-server": "^4.0.0"
  }
}



Solution 1:[1]

Alternatively, you could run the versions that are being used in the video. Have a look at the package.json file to see which versions you are currently using.

Installation of a specific version:

$ npm i [email protected] [email protected] [email protected]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tyler2P