NEXT_PUBLIC_GA_TRACKING_ID=UA-DEV-123456 DATABASE_URL=postgresql://user:pass@localhost:5432/dev_db NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_... Use python-dotenv or django-environ .
In Node.js, process.env is mutated at startup. If you change .env.development while the server is running, the app won't see the changes. Always restart your dev server after editing environment files. Pitfall 2: Boolean Parsing Environment variables are always strings. This fails: .env.development
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 load .env.development . Part 8: Troubleshooting Common .env.development Issues Problem: "My variables are undefined" Solution: Check the file location. The .env.development file must be in your project's root directory (where you run the command). Also, verify you have restarted the server. Problem: "My React app ignores .env.development " Solution: Ensure variables are prefixed with REACT_APP_ (CRA) or VITE_ (Vite). Non-prefixed variables remain server-only. Problem: "Git keeps tracking my environment files" Solution: Double-check your .gitignore . Add: If you change
But what exactly is .env.development , how does it differ from a plain .env file, and how can you use it like a senior engineer? This 3,000-word guide will cover everything from syntax to security best practices. In simple terms, .env.development is a plain text file used to store environment variables specifically for the development environment . The Core Concept Environment variables are key-value pairs injected into your application's process at runtime. A standard .env file might look like this: you create .env.local :
This couples your environment logic to your source code. With .env.development , the code simply reads process.env.API_URL —the file decides the value. The implementation varies slightly, but the philosophy is identical. Node.js + dotenv (Vanilla) Install dotenv :
PORT=3000 LOG_LEVEL=info You, as a developer, need to test on port 8080 with verbose logs. Instead of modifying the committed file (causing merge conflicts), you create .env.local :