javascript - 「wds」:无效的配置对象。Webpack 已使用与 API 模式不匹配的配置对象进行初始化
问题描述
我一直在尝试找到一种方法来分类/探索计算机上数百万个鼓声以进行音乐制作,并遇到了这个项目并克隆了这个 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.
解决方案
格式错误并使用文档中不存在的webpack.config.js
非标准密钥。我已更正错误 - 将您的替换为以下内容: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
};
推荐阅读
- python - python 3.9版中的blpapi
- html - 使用 RMarkdown 中的函数绘制要编织到 html 的绘图时出错
- c# - 没有显式映射的 EF Core 5.0 多对多关系 - 如何连接两个表?
- excel - VBA复制/粘贴循环不拉任何东西
- haskell - Haskell 变量不在范围内
- python - 将数据框中的每一行除以 Python 中的向量
- javascript - 如何只打开特定的模态窗口?
- python - 如何在 python 执行的 sql 语句中使用 hex(x ' ' )?
- javascript - 将代码移动到函数中时,React-leaflet LayersControl 引发错误
- vue.js - 选择单选按钮时,Vue组件不呈现条件内容