I’m trying to npm start my project and it returns the following error:
[webpack-cli] webpack Dev Server Invalid Options
options should NOT have additional properties
I’ve just freshly installed Webpack with the latest versions of everything, including a library for extracting metadata from music.
package.json:
{
"name": "quiz",
"version": "1.0.0",
"description": "A simple music quiz",
"main": "index.js",
"scripts": {
"start": "webpack serve --open",
"build": "webpack"
},
"author": "",
"license": "ISC",
"dependencies": {
"music-metadata-browser": "^10.0.0"
},
"devDependencies": {
"webpack": "^5.93.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.0.4",
"html-webpack-plugin": "^5.6.0",
"css-loader": "^7.1.2",
"style-loader": "^4.0.0"
}
}
webpack.config.js:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
clean: true,
},
module: {
rules: [
{
test: /.css$/i,
use: ['style-loader', 'css-loader'],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: 'index.html',
}),
],
devServer: {
static: {
directory: path.join(__dirname, 'dist'),
},
open: true,
compress: true,
port: 9000,
hot: true,
},
mode: 'development',
};
After researching the error I figured it might be a problem related to the versions, so I double-checked that all the versions matched in the .json file and I’m still getting the same error.
Xhm7DxdjGc is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.