报错信息
ERROR Failed to compile with 47 errors
error in ./node_modules/@vueuse/core/index.mjs
Can't import the named export 'watchWithFilter' from non EcmaScript module (only default export is available)
Can’t import the named export ‘xxx’ from non EcmaScript module (only default export is available)
发现问题
今天准备搭建一个新vue项目时,发现引入element-plus时报错了。很莫名其妙的,因为老项目也是这样引用的,仔细读文档发现element刚好在昨天更新到了1.1.0-beta.10版本,而我在安装时没有指定版本直接安装了最新版的,这个版本在使用webpack版本时才会出现,即使用了npm install element-plus --save
命令安装。
解决方法
在vue.config.js
中加入配置:
configureWebpack: {
module: {
rules: [
{
test: /\.mjs$/,
include: /node_modules/,
type: "javascript/auto"
},
]
}
},