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 { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, defaultRules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp?, strictExportPresence?, strictThisContextOnImports? }
-> Options affecting the normal modules (NormalModuleFactory
).
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! newreact@1.0.0 start: webpack
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the newreact@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
NormalModuleFactory
答案 0 :(得分:0)
您真的需要告诉我们您正在使用的webpack版本并发布您的webpack.config.js文件,但我会尝试并提供帮助。我假设webpack 4。
日志的这一位说你编写webpack.config.js文件的方式有问题。
Webpack has been initialized using a configuration object that does not match the API schema.
这一行进一步描述了这个问题。
configuration.module has an unknown property 'loaders'.
然后继续告诉您哪些属性有效,并且您将看到未列出装载程序。在webpack 4中,您需要使用'规则'而不是'加载器'。
These properties are valid: object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, defaultRules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp?, strictExportPresence?, strictThisContextOnImports? }
您的模块对象应该类似于以下内容,因此可能take a look at this page并将模块对象与您自己的模块对象进行比较。
module: {
rules: [
{
test: /\.css$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
modules: true
}
}
]
}
]
}
希望有所帮助。