vuepress加载element-ui时报错Cannot find module ‘core-js/library/fn/object/assign

搭建vuepress文档,想要在文档中展示我基于element ui写的组件demo,故创建文件enhanceApp.js

enhanceApp.js的配置如下

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import demos from '../../src/examples'
import Components from '../../src/packages'

function parseComponentsName (name) {
  return 'mt' + name.replace(/[A-Z]/g, c => '-' + c.toLowerCase())
}

const install = function (Vue, options) {
  Object.keys(demos).forEach(name => {
    Vue.component(name, demos[name])
  })
  Object.keys(Components).forEach(name => {
    Vue.component(parseComponentsName(name), Components[name])
  })
}

export default ({
  Vue
}) => {
  Vue.use(ElementUI)
  Vue.use({install})
}

配置没有问题,但是在运行vuepress dev docs时报错Cannot find module 'core-js/library/fn/object/assign等错误信息,错误完全围绕core-js

跟着google走,大部分文档都让我升级core-js,然而并没有用

最后在https://github.com/vuejs/vuepress/issues/2275中发现,原来是element ui依赖core-js的2.x版本,而web项目依赖core-js的3.x版本导致的(错误信息中没有关于element-ui的,真坑爹)

改core-js的版本是不可能的,安装依赖yarn add async-validator@1.11.5 / npm install async-validator@1.11.5就可以解决问题了

 

另外:

npx vuepress info

npx vuepress info,如果出现vue包版本不一致的问题,记得将版本安装一致哦

评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值