reactjs configuration.module 有一个未知的属性 'loaders'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49370849/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
configuration.module has an unknown property 'loaders'
提问by S.M_Emamian
my output of error:
我的错误输出:
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).
无效的配置对象。Webpack 已使用与 API 架构不匹配的配置对象进行初始化。- configuration.module 有一个未知的属性 'loaders'。这些属性是有效的: object { exprContextCritical?、exprContextRecursive?、exprContextRegExp?、exprContextRequest?、noParse?、rules?、defaultRules?、unknownContextCritical?、unknownContextRecursive?、unknownContextRegExp?、unknownContextRequest?、wrappedContextRecursive?、wrappedContextRecursive?、 ?,strictExportPresence?,strictThisContextOnImports? } -> 影响正常模块的选项 (
NormalModuleFactory)。
my webpack.config.js:
我的 webpack.config.js:
var webpack = require('webpack');
var path = require('path');
var BUILD_DIR = path.resolve(__dirname, 'src/client/public');
var APP_DIR = path.resolve(__dirname, 'src/client/app');
var config = {
entry: APP_DIR + '/index.jsx',
module : {
loaders : [
{
test : /\.jsx?/,
include : APP_DIR,
loader : 'babel-loader'
}
]
},
output: {
path: BUILD_DIR,
filename: 'bundle.js'
}
};
module.exports = config;
my webpack version:
我的 webpack 版本:
[email protected]
回答by S.M_Emamian
回答by Shawn Stephens
Use rulesin webpack 4 instead of loaders.
rules在 webpack 4 中使用而不是loaders.
回答by Anshul
Above given answers are working but we can resolve this issue by changing webpack and webpack-dev-server version to
上面给出的答案是有效的,但我们可以通过将 webpack 和 webpack-dev-server 版本更改为
"webpack": "3.8.1",
"webpack-dev-server": "2.9.4"
It can also solve the issue. Hope it will help.
它也可以解决问题。希望它会有所帮助。
回答by MattG
You should use the migration utilityto migrate your webpack config files, it worked for me.
您应该使用迁移实用程序来迁移您的 webpack 配置文件,它对我有用。
The migration documentationis also useful.
该迁移文档也很有用。

