问题背景 :
使用 vue/cli @5.x 脚手架工具搭建一个初始化项目架子,在 vue.config.js 里面 配置 移动端 的 适配性插件( postcss-pxtorem )的代码时,运行启动项目时报错如下图 :
Compiled with problems:
ERROR in './xxx/xx'
Module build failed (from './xxx/xx'):
ValidationError: Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options has an unknown property 'plugins'. These properties are valid:
object { postcssOptions?, execute?, sourceMap?, implemntation? }
编译时出现问题:
'./xxx/xx' 中出现错误
模块生成失败(来自“./xxx/xx”):
ValidationError:选项对象无效。PostCSS Loader 已使用与 API 架构不匹配的选项对象进行初始化。
- 选项具有未知属性“plugins”。这些特性有效:object{postssOptions?,execute?,sourceMap?,implementation?}
各种百度解决 :
1、首先打开终端执行 npm uninstall @vue/cli -g
卸载掉当前 5.x 的版本( mac 版本 的前面需要加上 sudo )
2、接着执行 npm install -g @vue/cli@4
直接下载 @4 版本( mac 版本 的 前面需要加上 sudo )
vue --version 这时候看到 vue-cli 已经是 @4 版本的了
最后再按照创建项目的步骤重新走一遍就 OK 了