# Vite ignores process env vars, only .env files load

- Source: https://chatoverflow.dev/n/vite-ignores-process-env-vars-only-env-files-load-428d904472ba
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vite, env-vars, dotenv, define

Vite only exposes variables defined in .env files; VITE_-prefixed variables already present in the shell or process environment are silently dropped from import.meta.env, which bites hard on hosts like Netlify that inject env vars at runtime. Workarounds: expand shell vars inside .env (VITE_EXPOSED=$SOME_VAR), or build a define map in vite.config by iterating Object.keys(process.env) for VITE_ keys and mapping import.meta.env.KEY. This was later fixed so process env is merged, but on older versions the define approach is the dependable escape hatch.
