gulp时webpack报错:WebpackOptionsValidationError: Invalid configuration object. Webpack has been initial

错误信息如下:

E:\works\ES6>gulp
[20:37:23] Failed to load external module @babel/register
[20:37:23] Requiring external module babel-register
[20:37:26] Using gulpfile E:\works\ES6\gulpfile.babel.js
[20:37:26] Starting 'build'...
[20:37:26] Starting 'clean'...
[20:37:26] Finished 'clean' after 97 ms
[20:37:26] Starting 'css'...
[20:37:26] Finished 'css' after 39 ms
[20:37:26] Starting 'pages'...                                                                      [20:37:26] Finished 'pages' after 24 ms
[20:37:26] Starting 'scripts'...
E:\works\ES6\node_modules\webpack\lib\webpack.js:31
                throw new WebpackOptionsValidationError(webpackOptionsValidationErrors);
                ^
WebpackOptionsValidationError: 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`).
    at webpack (E:\works\ES6\node_modules\webpack\lib\webpack.js:31:9)                                  at Stream.<anonymous> (E:\works\ES6\node_modules\webpack-stream\index.js:148:38)
    at _end (E:\works\ES6\node_modules\through\index.js:65:9)
    at Stream.stream.end (E:\works\ES6\node_modules\through\index.js:74:5)
    at Stream.onend (internal/streams/legacy.js:44:10)
    at emitNone (events.js:111:20)                                                                      at Stream.emit (events.js:208:7)
    at drain (E:\works\ES6\node_modules\through\index.js:34:23)
    at Stream.stream.queue.stream.push (E:\works\ES6\node_modules\through\index.js:45:5)
    at Stream.end (E:\works\ES6\node_modules\through\index.js:15:35)

配置代码如下:

.pipe(gulpWebpack({
			module:{
				loaders:[{
					test:/\.js$/,
					loader:'babel'
				}]
			}
		}),null,(err,stats)=>{
			log(`Finished '${colors.cyan('scripts')}'`,stats.toString({
				chunks:false
			}))
		})

百度觅得解决办法:

点此传送 -> 新手运行webpack 报错: unknown property ‘loaders’.

  • 直接将原来的loaders改为rules就可以了!
  • 原因是webpack不同的版本有不同的写法…
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值