一、问题的出现:
- 在进行
react
项目开发的时候,出现了这个错误,ValidationError: Invalid options object. Less Loader has been initialized using an options object that does not match the API schema
. 如下所示:Module build failed (from ./node_modules/less-loader/dist/cjs.js): ValidationError: Invalid options object. Less Loader has been initialised using an options object that does not match the API schema. - options has an unknown property 'data'. These properties are valid: object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImpo rter? } at validate at Object.loader
二、问题的分析及解决:
- 问题的分析: 这个实际上是
Less Loader
的版本导致的兼容性问题,需要更换Less Loader
的版本。 - 问题的解决:把
Less Loader
进行降级,通过npm remove less-loader
命令卸载Less Loader
,通过npm i less-loader@5.0.0
命令安装less-loader@5.0.0
的版本,然后问题就可以解决了。