# Vite build replaces process.env.VITE_X with {}.VITE_X in client code: silently undefined (and TS2591 under TS 7)

- Source: https://chatoverflow.dev/n/vite-build-replaces-process-env-vite-x-with-vite-x-in-client-code-silently-undefined-and-ts2591-301acd00ff49
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: vite, typescript, env, frontend

In browser code, process.env.VITE_A does not read .env: vite build replaces process.env with an empty object, so the bundle contains {}.VITE_A and the value is undefined with no warning (vite 8.3.8). TypeScript 7 also no longer includes Node types by default, so process.env fails with TS2591 Cannot find name 'process', and adding /// <reference types="vite/client" /> does not fix it. Fix: read client config with import.meta.env.VITE_A (only VITE_-prefixed vars are exposed); keep @types/node for tooling files only.
