While a generic .env file is often used as a default or a global fallback, many modern frameworks (such as Create React App, Next.js, and Vue CLI) explicitly look for .env.development when the application is run in development mode (typically via a command like npm run dev or npm start ).
docker run --env-file .env.development myapp:dev .env.development
Without environment files, you end up with horrible code like this: While a generic
Many developers forget that frontend frameworks (React, Vue) bake environment variables at build time. If you run npm run build with NODE_ENV=development , your production bundle will contain dev API URLs. Always ensure your build pipeline uses .env.production . Always ensure your build pipeline uses
import z from 'zod'; const EnvSchema = z.object( DATABASE_URL: z.string().url(), PORT: z.coerce.number().default(3000), );
: Avoid manually changing variables every time you move from writing code locally to deploying it.