Zum Inhalt springen
Zur Hauptnavigation springen
Zum Footer springen

.env.development — Full HD

While this article focuses on .env.development, a complete setup includes .env.test.

| File | Environment | Use case | | :--- | :--- | :--- | | .env.development | Dev server | Live coding, hot reload, local DB | | .env.test | CI/CD & local tests | Isolated runs, deterministic data | | .env.production | Live servers | Real secrets, scaled databases |

Example .env.test:

NODE_ENV=test
DATABASE_URL=sqlite::memory:
DISABLE_EMAIL_SENDING=true
MOCK_JWT_SECRET=test-secret-only

Your test runner (Jest, Mocha, PyTest) should automatically load .env.test and never load .env.development. .env.development


If you store production AWS keys in a .env file that you accidentally commit to GitHub, bots will find them within minutes. .env.development is rarely committed (but can be, if it contains only harmless dev defaults).

If you use Docker for local development, you can bridge your .env.development directly into your containers.

# docker-compose.yml
version: '3.8'
services:
  api:
    build: .
    env_file:
      - .env.development
    ports:
      - "$PORT:3000"

Now, running docker-compose up automatically injects your dev variables. While this article focuses on

In the modern world of software development, the line between "it works on my machine" and production failure is often drawn by one thing: configuration. Environment variables have become the industry standard for managing this configuration, and at the heart of this practice lies a specific, powerful file: .env.development.

If you have ever cloned a repository, run npm install, and then spent 30 minutes trying to figure out why the API calls are failing, you have felt the pain of missing or misconfigured environment files. This article is your complete guide to understanding, implementing, and mastering .env.development.

Imagine every time you run npm run dev, your code sends a request to a paid third-party API (like Twilio or OpenAI). You would burn through your budget in an afternoon. The .env.development file allows you to substitute real APIs with mock endpoints or local sandboxes. Your test runner (Jest, Mocha, PyTest) should automatically

# .env.production
PAYMENT_GATEWAY=https://api.stripe.com/v1

New developers joining a team should clone the repo and run npm start without fighting database connections. A well-tuned .env.development provides sane defaults (e.g., a local SQLite database vs. a cloud PostgreSQL instance).

TypeScript developers are adopting tools like t3-env or zod to parse environment variables. Example:

import  z  from 'zod';
const EnvSchema = z.object(
  DATABASE_URL: z.string().url(),
  PORT: z.coerce.number().default(3000),
);

// Loaded from .env.development const env = EnvSchema.parse(process.env);

This ensures your .env.development is validated before the app starts.