Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

env-doctor 🩺

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

Why

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 1 on errors
  • --fix mode appends missing keys to your .env automatically

Install

npm install -g env-doctor

Or use it without installing via npx:

npx env-doctor

Usage

# 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

Options

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

Exit codes

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)

Use in CI

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)

Requirements

  • Node.js ≥ 18

License

MIT

About

CLI to diagnose missing environment variables

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages