how to avoid "Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema."

14,648

Can you try with this scripts?

"scripts": {
  "start": "webpack-dev-server --mode development --open --hot",
  "build": "webpack --mode production"
}

Also, make sure webpack config is called webpack.config.js?

Share:
14,648
Mind Gauge
Author by

Mind Gauge

Updated on August 01, 2022

Comments

  • Mind Gauge
    Mind Gauge almost 2 years

    I am working with webpack to setup a react project. but after running command below

    npm start
    

    I have got following error in terminal

    × 「wds」: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
     - configuration.entry['main'] should not contain the item '—' twice.
       -> A non-empty array of non-empty strings
    

    here is my webpack.config.js file

    const path = require('path');
    const HWP = require('html-webpack-plugin');
    module.exports = {
        entry: path.join(__dirname, '/src/index.js'),
        output: {
            filename: 'build.js',
            path: path.join(__dirname, '/dist')},
        module:{
            rules:[{
               test: /\.js$/,
               exclude: /node_modules/,
               loader: 'babel-loader'
            }]
        },
        plugins:[
            new HWP(
               {template: path.join(__dirname,'/src/index.html')}
            )
        ]
    }
    

    And below is the code for package.json

    {
      "name": "aragon-connect-1.1",
      "version": "1.0.0",
      "description": "",
      "scripts": {
        "start": "webpack-dev-server — mode development — open — hot",
        "build": "webpack — mode production"
      },
      "author": "Author Name",
      "license": "ISC",
      "dependencies": {
        "react": "^16.13.1",
        "react-dom": "^16.13.1"
      },
      "devDependencies": {
        "babel-core": "^6.26.3",
        "babel-loader": "^8.1.0",
        "babel-preset-env": "^1.7.0",
        "babel-preset-react": "^6.24.1",
        "html-webpack-plugin": "^4.3.0",
        "webpack": "^4.44.1",
        "webpack-cli": "^3.3.12",
        "webpack-dev-server": "^3.11.0"
      }
    }
    
    

    Can anyone let me know about where I am getting wrong? Thanks in advance

    • David González
      David González almost 4 years
      Not sure if it's a formatting problem, but I find this very strange: — mode development. It should be --mode development, with two hyphens not followed by space. Same with the other parameters in start and build.
    • Mind Gauge
      Mind Gauge almost 4 years
      thanks for your reply But it does not help in my case