Skip to content
This repository has been archived by the owner on Jul 18, 2019. It is now read-only.

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. #48

Open
khromov opened this issue Nov 28, 2017 · 4 comments

Comments

@khromov
Copy link

khromov commented Nov 28, 2017

I believe the documentation is incorrect, as the code example gives an error.

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration has an unknown property 'jshint'. These properties are valid:
   object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }
   For typos: please correct them.
   For loader options: webpack 2 no longer allows custom properties in configuration.
     Loaders should be updated to allow passing options via loader options in module.rules.
     Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:
     plugins: [
       new webpack.LoaderOptionsPlugin({
         // test: /\.xxx$/, // may apply this only for some modules
         options: {
           jshint: ...
         }
       })
     ]

What kind of issue are you submitting?
Bug Report

Please tell us your

  • Webpack version 3.8.1
  • jshint-loader version 0.8.4
  • jshint version Whichever jshint-loader installs
  • OS OSX

Use this configuration and run webpack:

const path = require('path');
const webpack = require('webpack');

module.exports = {
  entry: './js/init.js',
  watch: true,
  output: {
    path: path.resolve(__dirname, 'js'),
    filename: 'init.min.js'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: [/node_modules/],
        query: {
          presets: ['es2015'],
          plugins: ["transform-object-assign", "transform-runtime"]
        }
      }
    ],
    rules: [
      {
        test: /\.js$/, // include .js files
        enforce: "pre", // preload the jshint loader
        exclude: /node_modules/, // exclude any and all files in the node_modules folder
        use: [
          {
            loader: "jshint-loader"
          }
        ],
      }
    ]
  },
  jshint: {
    // any jshint option http://www.jshint.com/docs/options/
    // i. e.
    camelcase: true,

    // jshint errors are displayed by default as warnings
    // set emitErrors to true to display them as errors
    emitErrors: false,

    // jshint to not interrupt the compilation
    // if you want any file with jshint errors to fail
    // set failOnHint to true
    failOnHint: false,

    // custom reporter function
    reporter: function(errors) { }
  },
  stats: {
    colors: true
  },
  //devtool: 'source-map'
};
@khromov
Copy link
Author

khromov commented Nov 28, 2017

A correct solution is provided here, the documentation should be updated:
https://stackoverflow.com/a/45274620/2572827

@shellscape
Copy link
Contributor

We're working on getting this repo up to date. Hang tight.

@Alessandra-Nastassja
Copy link

If it does not work, change the path of the files to a simpler one that will work

@rahul6612
Copy link

Version: webpack 4.28.1

that's the solution :
step1: npm install webpack-cli -g
step2: change your webpackconfig.js file to this one

`
var path = require('path');

module.exports = {
entry: './main.ts',
resolve: {
extensions: ['.webpack.js', '.web.js', '.ts', '.js']
},
module: {
rules: [
{ test: /.ts$/, loader: 'ts-loader' }
]
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
}
};
`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants