Have you ever deployed your Node.js app, only to see it crash due to a missing or incorrect environment variable?
If yes — you’re not alone.
Environment variables (.env
files) are essential for configuring secrets, ports, database URLs, and more — but they’re also fragile and invisible. A single missing or mistyped key can break your entire app in production, CI/CD, or even onboarding new teammates.
That’s exactly the kind of problem I wanted to solve when I created:
env-check-ts
A simple, TypeScript-powered CLI that validates your.env
file against a schema and even auto-generates.env.example
.
🤷♂️The Problem We Often Ignore
Let’s say you’ve got a .env
like this:
NODE_ENV=prod
PORT=3000
DATABASE_URL=https://secure-db.com
What if:
- NODE_ENV was expected to be "production", not "prod"?
- PORT was accidentally deleted?
- You forgot to include DATABASE_URL in .env.example?
These bugs don’t get caught until runtime... and by then it’s too late.
🧪The Solution — env-check-ts
env-check-ts solves this with schema validation, powered by Zod. It ensures your .env is:
✅ Present
✅ Complete
✅ Valid by type and value
You can also auto-generate a neat .env.example based on your schema.
🧑💻 Try it Now
npm install -g env-check-ts
or use via:
npx env-check-ts validate
Full docs + GitHub: Here
🤔Why I Built This
As a developer working on open-source and team projects, I faced recurring issues:
- CI/CD failing due to missing envs
- Confusion over .env files in onboarding
- Forgetting to update .env.example
I wanted something:
- Simple and Type-safe
- And powered by a schema — not just regex
So env-check-ts was born. It’s lightweight, zero-config, and developer-first.
🔮What's Next?
I'm actively improving this tool. Upcoming features:
- Support for .env.production, .env.test, etc.
- Ability to redact secrets when generating .env.example
- VS Code extension for inline validation
- Auto-run as part of CI/CD pipelines
Have suggestions or ideas? I’d love your feedback!
🫡Final Words
If this tool helped you or your team:
⭐️ Give it a star on GitHub
🗣 Share it with a dev friend or a crazy techy
📥 DM or comment — I'd love to hear your thoughts!
Thanks for reading 🙌
Built with ❤️ by Divyansh Kumar
Top comments (0)