dotenv-align
v1.0.0
Published
Trace environment variables and sync with .env.example
Downloads
90
Maintainers
Readme
Stop Breaking Production with Missing Env Vars
The Problem
You're coding away, and you add a new feature that needs an API key.
// src/payment.js
const stripeKey = process.env.STRIPE_SECRET_KEY; // You added this locally
await processPayment(stripeKey);It works on your machine. You push the code.
Your teammate pulls it, runs the app, and it crashes.
Why? Because you forgot to add STRIPE_SECRET_KEY to .env.example.
The Solution: dotenv-align
dotenv-align scans your code. If you use a process.env variable that isn't in your .env.example, it warns you immediately.
1. Install it
npm install -g dotenv-align2. Run it
dotenv-align checkWhat you see:
Tracing environment variables...
Found 1 untraced variable:
┌────────────────┬───────────┬──────────────────────┐
│ Variable │ Status │ Location │
├────────────────┼───────────┼──────────────────────┤
│ STRIPE_SECRET │ MISSING │ src/payment.js:12 │
└────────────────┴───────────┴──────────────────────┘
Tip: Add STRIPE_SECRET to .env.example to fix this.Features at a Glance
- Multi-File Support: Checks against
.env.example,.env.staging,.env.productionautomatically. - Smart Scanning: Ignores commented-out code.
- Zero Config: Just run it. It finds your files.
CLI Reference
dotenv-align check
Scans your code and verifies env vars against your example files.
-e, --env <files...>: Specify exact env files to check against.- Example:
dotenv-align check -e .env.development .env.staging
- Example:
dotenv-align report
Generates a file report of your environment variable usage.
-f, --format <type>: Format of the report (jsonortxt). Default:json.-o, --output <path>: Path to save the report. Default:./reports/env-report.json.-e, --env <files...>: Specify env files to include in the report.
Global Options
-h, --help: Display help information.-V, --version: Output the version number.
Get Started
Don't let missing env vars waste your team's time.
npx dotenv-align check