vue3 引入 element-ui 報錯 - ERR! ERESOLVE unable to resolve dependency tree

xiluhua發表於2024-06-24

vue3 引入 element-ui 報錯。

PS E:\ws06\test-new\20240620-syt\syt-01> npm i element-ui@2.3.5 -S
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: syt-01@0.0.0
npm ERR! Found: vue@3.4.30
npm ERR! node_modules/vue
npm ERR!   vue@"^3.4.21" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^2.5.2" from element-ui@2.3.5
npm ERR! node_modules/element-ui
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Administrator.DESKTOP-S92EN3R\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator.DESKTOP-S92EN3R\AppData\Local\npm-cache\_logs\2024-06-24T13_55_02_530Z-debug-0.log

問題原因:element-ui不適配vue3,官方已將vue3版本的更新為element-plus

解決:

npm install element-plus --save

引入

import elementPlus from 'element-plus'
import 'element-plus/theme-chalk/index.css';
app.use(elementPlus);


————————————————

版權宣告:本文為博主原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處連結和本宣告。

原文連結:https://blog.csdn.net/LxyingINGing/article/details/136021994

相關文章