Diagnose missing or empty environment variables before they break your app.
env-doctor compares your .env against .env.example and clearly reports what's missing, what's empty, and what's fine — with an optional --fix flag to patch your .env automatically.
✖ Missing (2)
SECRET_KEY # your-secret-key-here
DATABASE_URL # postgres://localhost/mydb
⚠ Empty / blank (1)
STRIPE_KEY # sk_live_...
✔ All good (4/7 keys set)
3 issues found out of 7 variables
Every project has a .env.example. Every developer has broken a deployment because someone added a new variable and forgot to tell everyone. env-doctor catches that in one command.
- Zero dependencies
- Works with any stack (Node, Python, Ruby, Go…)
- CI/CD friendly — exits with code
1on errors --fixmode appends missing keys to your.envautomatically
npm install -g env-doctorOr use it without installing via npx:
npx env-doctor# Run in your project root (looks for .env.example and .env by default)
env-doctor
# Custom file paths
env-doctor -e .env.example -f .env.local
# Fail on empty/blank values too
env-doctor --strict
# Auto-append missing keys to .env
env-doctor --fix
# Suppress output, only exit code (good for CI)
env-doctor --quiet| Flag | Short | Default | Description |
|---|---|---|---|
--example |
-e |
.env.example |
Path to the example/template file |
--env |
-f |
.env |
Path to your actual env file |
--fix |
false |
Append missing keys to your .env |
|
--strict |
false |
Also fail on empty/blank values | |
--quiet |
-q |
false |
Suppress all output (exit code only) |
--help |
-h |
Show help |
| Code | Meaning |
|---|---|
0 |
All required variables are present (and non-empty if --strict) |
1 |
One or more variables are missing (or empty in --strict mode) |
Add to your pipeline to catch env issues before deployment:
# GitHub Actions example
- name: Check environment
run: npx env-doctor --strict --quiet# Pre-commit hook (.git/hooks/pre-commit)
npx env-doctor --quiet || (echo "Fix your .env first!" && exit 1)- Node.js ≥ 18
MIT