书写 vue3 + vite + element plus 时 引入 element css报错:
[vite] Internal server error: Failed to resolve import "../node_modules/element-plus/lib/theme-chalk/index.css" from "src\main.js". Does the file exist?
检查后得知:
import '../node_modules/element-plus/lib/theme-chalk/index.css' // 多了层 lib 文件夹
import '../node_modules/element-plus/theme-chalk/index.css' // 去掉lib 后就可以了
import 'element-plus/theme-chalk/index.css' // 去掉lib 后就可以了(写成这样也可以)
main.js
![](https://i-blog.csdnimg.cn/blog_migrate/922d5fe64afc16344482041d39afef14.png)
element 引入成功:
![](https://i-blog.csdnimg.cn/blog_migrate/bef276759cfa7ba926d5b68c55564940.png)