Error in require.context in vue3 vite

In the vue2 version, I usually use require. Context to get all the files of a file

require.context('./modules', true, /\.js$/)

Errors will be reported when using vue3 vite


go to the vite official document and find the official provision method as follows

import.meta.globEager("./module/*.js") 


Read More: