Vite · Configuration
VITE0012Prefer direct import.meta.env access
Finds Vite env code that should use the supported direct import meta env access pattern instead.
vite-doctor/viteconfigurationinfoNo fix
Why it happens
Direct import.meta.env.KEY access lets Vite statically replace known values and tree-shake branches; aliasing the whole object obscures those keys.
Fix
Use the Vite-supported direct import meta env access pattern instead.
Example
Use direct env access
Before
const env = import.meta.env
const apiBase = env.VITE_API_BASE
After
const apiBase = import.meta.env.VITE_API_BASE
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 --extends auto,vite/strict --rules vite/env/prefer-direct-import-meta-env-access