D
D
Denis2017-02-07 21:58:41
webpack
Denis, 2017-02-07 21:58:41

Does Webpack give a strange error when building?

Hello. I started learning Webpack based on Ilya Kantor's screencast. When I added the resolve and resolveLoader settings in the webpack.config.js file, and ran the webpack command, I got an error message that I can't overcome in any way:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.resolve has an unknown property 'modulesDirectories'. These properties are valid:
   object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }
 - configuration.resolve.extensions[0] should not be empty.
 - configuration.resolveLoader has an unknown property 'moduleTemplates'. These properties are valid:
   object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }
 - configuration.resolveLoader.extensions[0] should not be empty.

What's wrong with assembly?
webpack.config.js:
var webpack = require('webpack');
var NODE_ENV = process.env.NODE_ENV || 'development';

module.exports = {
    entry: "./js/main",
    output: {
        filename: "js/build.js",
        library: 'main'
    },
    watch: NODE_ENV == 'development',
    watchOptions: {
        aggregateTimeout: 100
    },
    devtool: NODE_ENV == 'development' ? 'cheap-inline-module-source-map' : null,
    plugins: [
        new webpack.DefinePlugin({
            NODE_ENV: JSON.stringify(NODE_ENV),
            LANG: JSON.stringify('ru')
        })
    ],
    resolve: {
        modulesDirectories: ['node_modules'],
        extensions: ['', '.js']
    },
    resolveLoader: {
        modulesDirectories: ['node_modules'],
        moduleTemplates: ['*-loader'],
        extensions: ['', '.js']
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                loader: 'babel'
            }
        ]
    }
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2017-02-08
@maxfarseer

Check the webpack version, Kantor had a screencast for the 1.xx branch, and you probably have webpack 2.xx installed by default

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question