「wds」:无效的配置对象。已使用与API模式不匹配的配置对象初始化了Webpack

时间:2019-04-08 16:25:33

标签: javascript node.js webpack frontend webpack-dev-server

我一直在尝试寻找一种方法来对计算机上的数百万个鼓音进行分类/探索以进行音乐制作,并遇到了this project和克隆this github

运行npm start后,出现Invalid configuration object错误。完整日志:

User-2:aiexperiments-drum-machine-master User$ npm start

> drums@1.0.0 start /Users/User/Dropbox/aiexperiments-drum-machine-master
> webpack-dev-server

✖ 「wds」: 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:
   object { defaultRules?, exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, strictExportPresence?, strictThisContextOnImports?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp? }
   -> Options affecting the normal modules (`NormalModuleFactory`).
 - configuration.resolve has an unknown property 'modulesDirectories'. These properties are valid:
   object { alias?, aliasFields?, cachePredicate?, cacheWithContext?, concord?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }
   -> Options for the resolver
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! drums@1.0.0 start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the drums@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

1 个答案:

答案 0 :(得分:0)

webpack.config.js格式错误,并且使用了the docs中不存在的非标准密钥。我已纠正错误-将您的webpack.config.js替换为以下内容:

/**
 * Copyright 2016 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

var webpack = require("webpack");

var PROD = JSON.parse(process.env.PROD_ENV || '0');

module.exports = {
    "context": __dirname,
    entry: {
        "Main": "app/Main",
    },
    output: {
        filename: "./build/[name].js",
        chunkFilename: "./build/[id].js",
        sourceMapFilename : "[file].map",
    },
    resolve: {
        modules: [
            "node_modules", 
            "node_modules/tone", 
            "app"
        ],
    },
    plugins: PROD ? [
        new webpack.optimize.UglifyJsPlugin({minimize: true}),
        new webpack.DefinePlugin({__DEV__: true})   
    ] : [],
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: [/node_modules/],
                loader: 'jshint-loader'
            },
            {
                test: /\.scss$/,
                loader: "style!css!autoprefixer!sass"
            },
            {
                test: /\.json$/,
                loader: "json-loader"
            },
            {
                test: /\.(png|gif)$/,
                loader: "url-loader",
            },
            {
                test   : /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
                loader : "file-loader?name=images/font/[hash].[ext]"
            }
        ]
    },
    watch: true

};