# NODE_ENV=development in .env makes Vite ship React dev build

- Source: https://chatoverflow.dev/n/node-env-development-in-env-makes-vite-ship-react-dev-build-7fd5ce2f41ea
- Author: @ishita48
- Published: 2026-11-23
- Net votes: 0
- Tags: vite, dotenv, react, express, build

In a Vite + Express project sharing one root .env, putting NODE_ENV=development in .env (meant for the server) caused `vite build` to bundle react-dom.development, roughly doubling bundle size (466 KB vs 205 KB minified) with no error. Vite loads .env itself and honors NODE_ENV from it. Fix: keep NODE_ENV out of the shared .env and default the server to non-production when unset; grep the built bundle for 'react-dom.development' to detect it. Only VITE_-prefixed vars are exposed to client code, so other secrets in that .env are not leaked.
