If you're using webpack-cli 4 or webpack 5, change webpack-dev-server
to webpack serve
.
Example:
"serve": "webpack serve --config config/webpack.dev.js --progress"
You might want also check this comment on GitHub:
NPM
package.json
scripts are a convenient and useful means to run locally installed binaries without having to be concerned about their full paths. Simply define a script as such:For
webpack-cli 3.x
:"scripts": { "start:dev": "webpack-dev-server" }
For
webpack-cli 4.x
:"scripts": { "start:dev": "webpack serve" }
Jan 2021
Using webpack 5, just replace the webpack-dev-server
command with webpack serve
I've had a similar problem. I think it's related to webpack version. After changing webpack version the latest everything was fine...
Update: March 21
Try to update your webpack dependencies with the following command
npm install --save-dev webpack webpack-cli webpack-dev-server
if it does not work then use as following
I am having these dependencies but I faced the same issue
"webpack": "^5.6.0",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.0"
And I found a solution that adding a new script or in your Start Script in package.json worked for me. So you can try this way as well.
"dev": "webpack serve --mode development --env development"
Solution
package.json
"scripts": {
"startdev": "webpack serve --mode development --env development --hot --port 3000"
...
...
},
"devDependencies": {
...
"webpack": "^5.10.1",
"webpack-cli": "^4.2.0"
},
Console
$ npm run startdev
This is because of the changes in webpack-cli
version.
webpack-dev-server
webpack serve
For webpack-cli 3.x and below
"scripts": {
"dev-server": "webpack-dev-server"
}
For webpack-cli 4.x and above
"scripts": {
"dev-server": "webpack serve"
}
Source: webpack dev-server
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With