A novice runs webpack and reports an error: unknown property 'loaders'..

webpack.config.js:
var webpack = require("webpack");
var path = require("path");
module.exports = {
        entry: "./src/app.js",
        output: {
            path: path.resolve(__dirname,"./bin"),
            filename: "app.bundle.js"
        },
        module: {
          loaders: [
             {
               test: /\.js$/,
               exclude: /(node_modules|bower_components)/,
               loader: "babel-loader",
               query: {
                   presets: ["es2015"]
                }
          }
        ]
    }
    

error is reported when executing the webpack command:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.configuration.module has an unknown property "loaders". These properties are valid:

I checked that webpack-v is 3.2.0
I replaced the loaders character under module with rules without making a mistake.
I checked on the Internet. It seems that the configuration of webpack1, and webpack2 is different.
I don"t know if my computer is equipped with webpack1 and webpack2,. I have checked that other projects are used by rulse, without loaders,. Is webpack1 not used much, or what?

Feb.28,2021

webpack v2 all use rules


change the loaders in module to rules


this. I also encountered these problems when learning before. Different versions of webpack configuration files are written differently. You can carefully check the version of the project webpack, and then go to the document to find the specific writing method.

Menu