Lake's Blog Lake's Blog
首页
  • 博客搭建

    • 搜索引擎
    • SEO优化
    • 问题记录
  • Vue

    • 问题记录
  • 开发

    • Spring
  • 数据库及中间件

    • Elasticsearch
    • SQL
  • 杂谈

    • 杂谈
  • 微服务

    • nacos
    • CAS
  • 算法说明

    • algorithm
  • leetCode

    • leetCode
  • 代理

    • Nginx
  • Linux

    • ubuntu
  • Docker
  • 数据库
  • 友情链接
  • openwrt
关于
  • 网站
  • 资源
  • 分类
  • 标签
  • 归档
GitHub

Lake Liu

很菜的程序员
首页
  • 博客搭建

    • 搜索引擎
    • SEO优化
    • 问题记录
  • Vue

    • 问题记录
  • 开发

    • Spring
  • 数据库及中间件

    • Elasticsearch
    • SQL
  • 杂谈

    • 杂谈
  • 微服务

    • nacos
    • CAS
  • 算法说明

    • algorithm
  • leetCode

    • leetCode
  • 代理

    • Nginx
  • Linux

    • ubuntu
  • Docker
  • 数据库
  • 友情链接
  • openwrt
关于
  • 网站
  • 资源
  • 分类
  • 标签
  • 归档
GitHub
  • 博客搭建

    • 搜索引擎

    • SEO优化

    • 问题记录

      • vuepress加载element-ui时报错
        • vuepress加载element-ui时报错Cannot find module ‘core-js/library/fn/object/assign
    • Markdown基本语法
    • Vue或VuePress添加不蒜子统计
  • VUE

vuepress加载element-ui时报错

# 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})
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

配置没有问题,但是在运行 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 的版本是不可能的,安装依赖 [email protected] 就可以 解决问题 了!

yarn add [email protected]
1
npm install [email protected]
1

另外:

npx vuepress info
1

img

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

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

编辑
#前端#VuePress#element-ui#Vue
上次更新: 2021/02/04, 01:34:23
使vuepress可以设置每个文章页的专属Keywords
Markdown基本语法

← 使vuepress可以设置每个文章页的专属Keywords Markdown基本语法→

最近更新
01
OpenWrt 路由器如何让 lan 口主机获得 ipv6 网络访问
04-19
02
MariaDB修改与迁移文件夹
03-24
03
mariadb全文索引
03-24
更多文章>
本站总访问量次 | 您是本站第位访问者
Theme by Vdoing | Copyright © 2020-2022 Lake Liu | MIT License | 背景图、Logo、头像设计@Drrizzee
  • 跟随系统
  • 深色模式
  • 浅色模式
  • 阅读模式