When vue3 introduces element plus, index.css cannot be found. Solve the problem

problem

In the project built by the latest Vue 3.2 + Vue cli 4.5, the method of introducing element plus in the old version of vue3 was initially followed, and all style files of element plus were introduced in main.js with the following statement:

import 'element-plus/lib/theme-chalk/index.css';

However, an error is reported:

Failed to compile.

./src/main.js
Module not found: Error: Can't resolve 'element-plus/lib/theme-chalk/index.css' in 'E:\sourceFiles\map-survey\src'

Since it was introduced in this way before, I felt it was outrageous when reporting an error

solve

The solution is also very simple. Now that you have installed the element plus dependency, you can’t find the file. The probability is that the path has changed. So I manually turned to node modules and found that the whole theme chat folder was moved.

Therefore, the statement introducing the style is changed to:

import 'element-plus/theme-chalk/index.css'

Error reporting can be solved. I hope I can help friends who have just contacted Vue + element

Similar Posts: