解決安裝element-plus 插件報錯

創(chuàng)建vue項目安裝element-plus 依賴以及element-plus 插件, 無法啟動服務(wù)

提示如下:

......
Module not found: Error: Package path ./lib/locale/lang/zh-cn is not exported from package ...項目路徑\node_modules\element-plus (see exports field in ...項目路徑\node_modules\element-plus\package.json)



ERROR in ./src/plugins/element.js 2:0-48
Module not found: Error: Package path ./lib/theme-chalk/index.css is not exported from package ...項目路徑\node_modules\element-plus (see exports field in ...項目路徑\node_modules\element-plus\package.json)
 @ ./src/main.js 5:0-51 7:0-18

ERROR in ./src/plugins/element.js 3:0-56
Module not found: Error: Package path ./lib/locale/lang/zh-cn is not exported from package ...項目路徑\node_modules\element-plus (see exports field in ...項目路徑\node_modules\element-plus\package.json)
 @ ./src/main.js 5:0-51 7:0-18

原因

安裝的element-plus 2.4.2 依賴, 里面部分代碼路徑更新了, 導(dǎo)致插件中的配置有問題.

解決方法

源文件 ...項目路徑\src\plugins\element-plus.js

import ElementPlus from 'element-plus'
import 'element-plus/lib/theme-chalk/index.css'
import locale from 'element-plus/lib/locale/lang/zh-cn'

export default (app) => {
  app.use(ElementPlus, { locale })
}

修改

import ElementPlus from 'element-plus'
import 'element-plus/theme-chalk/index.css'
import locale from 'element-plus/es/locale/lang/zh-cn'

export default (app) => {
  app.use(ElementPlus, { locale })
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容