Vite · Imports
VITE0022Use literal patterns in import.meta.glob
Reports import.meta.glob patterns that Vite cannot transform into module imports.
vite-doctor/viteimportserrorNo fix
Why it happens
Vite expands import.meta.glob during development and production builds. Its first argument must contain string literals, an array of string literals, or template literals without interpolation. Variables, concatenation, interpolated templates, and array spreads are unsupported even when their values are constant. Vite 7 rejects them during the transform; Vite 8 can instead omit their matching modules from the generated map.
Fix
Write the patterns directly inside import.meta.glob. To choose a module at runtime, use a literal glob to build the module map, then select a key from that map.
Example
Inline constant patterns
Before
const pattern = './pages/*.vue'
const pages = import.meta.glob(pattern)
After
const pages = import.meta.glob('./pages/*.vue')
Select a module after expanding a literal glob
Before
const loadPage = (name: string) => import.meta.glob(`./pages/${name}.vue`)
After
const pages = import.meta.glob('./pages/*.vue')
const loadPage = (name: string) => pages[`./pages/${name}.vue`]?.()
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm vite-doctor . --framework vite --rules vite/imports/require-static-glob-pattern