env-diff-now
v1.0.0
Published
Compare .env against .env.example and report missing, extra, and empty variables
Maintainers
Readme
env-diff-now
Compare .env against .env.example and catch missing, empty, or extra environment variables — before they break your build.
Why
Every team has that moment: someone adds a new required env var, forgets to tell anyone, and a teammate's app silently breaks (or worse, deploys with a missing secret). env-diff-now catches this in seconds.
Install
npm install --save-dev env-diff-nowOr run without installing:
npx env-diff-nowUsage
env-diff-now✖ Missing (2):
- DATABASE_URL
- STRIPE_SECRET_KEY
⚠ Empty (1):
- API_TIMEOUT
ℹ Extra — present in .env but not in .env.example (1):
- DEBUG_MODEOptions
| Flag | Description | Default |
|---|---|---|
| --env <path> | Path to actual env file | .env |
| --example <path> | Path to example env file | .env.example |
| --strict | Also fail (exit 1) on empty vars, not just missing | false |
| --quiet, -q | Only print output when there's a problem | false |
| --help, -h | Show help | |
| --version, -v | Show version | |
Exit Codes
0— all good1— missing (or empty, with--strict) variables found2—.env.examplefile not found
Use in CI
# .github/workflows/ci.yml
- name: Check env vars
run: npx env-diff-now --strictUse in postinstall
{
"scripts": {
"postinstall": "env-diff-now --quiet || echo 'Check your .env file — see above'"
}
}Tip:
postinstallruns even without a.envpresent on fresh clones —env-diff-nowhandles that gracefully and just reports every example var as missing, guiding new contributors to set things up correctly.
License
MIT
