| Problem | Solution | |---------|----------| | Variables are undefined | Ensure prefix (e.g., REACT_APP_ ) if using a frontend framework | | .env.development ignored in production | Check framework's env file loading rules – most ignore it when NODE_ENV=production | | Changes not applied | Restart the dev server | | dotenv overrides existing process.env | Use override: true (dotenv 16+) |
.env.local .env.*.local .env.production # But keep .env.development if it has safe defaults .env.development
const db = require('pg'); const api = require('axios'); | Problem | Solution | |---------|----------| | Variables
if (process.env.ENABLE_FEATURE) // "false" is truthy! const api = require('axios')
# .env.development NEXT_PUBLIC_GOOGLE_MAPS_KEY=dev_test_key_123 DATABASE_URL="postgresql://user@localhost:5432/dev_db"