I tried to fix this problem in several ways, so I have to start from the beginning.
I have a configuration file called webpack.dev.js , pictured here:
const path = require("path"); const HtmlWebpackPlugin = require("html-webpack-plugin"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); const CopyWebpackPlugin = require("copy-webpack-plugin"); module.exports = { entry: "./src/script.js", output: { filename: "bundle.js", path: path.resolve(__dirname, "dist") }, devtool: "inline-source-map", devServer: { contentBase: path.join(__dirname, "dist") }, module: { rules: [ { test: /\.js$/, exclude: /node_modules/, use: { loader: "babel-loader", options: { presets: ["env"] } } }, { test: /\.scss$/, use: ExtractTextPlugin.extract({ fallback: "style-loader", use: ["css-loader", "postcss-loader", "sass-loader"] }) } ] }, plugins: [ new HtmlWebpackPlugin({template: path.join("src", "index.html")}), new ExtractTextPlugin("style.css"), new CopyWebpackPlugin([{from: "src/images", to: "images"}]) ] };
So, I set the script to run in package.json to start the dev server
"start": "webpack-dev-server --config webpack.dev.js"
Now the problems begin. When I ran the script, I got the following error
Invalid configuration object. webpack-dev-server has been initialized using a configuration object that does not match the API schema. - configuration has an unknown property 'error'. These properties are valid: object { hot?, hotOnly?, lazy?, bonjour?, host?, allowedHosts?, filename?, publicPath?, port?, socket?, watchOptions?, headers?, clientLogLevel?, overlay?, progress?, key?, cert?, ca?, pfx?, pfxPassphrase?, requestCert?, inline?, disableHostCheck?, public?, https?, contentBase?, watchContentBase?, open?, useLocalIp?, openPage?, features?, compress?, proxy?, historyApiFallback?, staticOptions?, setup?, stats?, reporter?, noInfo?, quiet?, serverSideRender?, index?, log?, warn? }
As you can see, this error is very confusing because the error property does not exist in the configuration file
After trying different ways to fix this, I tried to simply remove the devServer property and start the dev server with the default settings.
But now that is getting weird. The result looks like if the web server was started twice:
Project is running at http://localhost:8080/ webpack output is served from / Project is running at http://localhost:8081/ webpack output is served from /
And after that, it logs several warnings about the presence of multiple modules with names that only differ in casing
Then after some searching, I found out about someone else who also had this unknown property 'error' problem, and the reason this happened to him was because he was running in the background of http-server .
So my theory is that for some reason the webpack-dev server runs twice, in parallel, and creates a race condition or error that triggers this unknown property 'error' problem.
I found two more people with similar problems, and they were fixed by simply adding inject: false to the HtmlWebpackPlugin configuration HtmlWebpackPlugin . Doing this did not make the error disappear, and when it was run without the devServer configuration, it simply deleted all js and css from the page, because it does not enter the <link> and <script> in html.
At this moment, I have no idea how to fix this problem, and why I am asking if anyone can help me.