Back to articles
I built a CLI tool that auto-detects missing environment variables — no schema needed

I built a CLI tool that auto-detects missing environment variables — no schema needed

via Dev.toAkash Gupta

Every Node.js developer has faced this at least once: App crashes in production. "Cannot read property of undefined." 2 hours of debugging later — someone forgot to set DATABASE_URL. I got tired of this. So I built dotenv-audit — a CLI tool that scans your actual code, finds every process.env usage, and tells you exactly what's missing. The Problem with Existing Tools dotenv → loads .env file. Doesn't validate anything. envalid → validates, but you have to write a schema manually: // With envalid - you write this for EVERY variable const env = cleanEnv ( process . env , { DATABASE_URL : str (), JWT_SECRET : str (), PORT : port ({ default : 3000 }), REDIS_HOST : str (), // ... 20 more lines }) The problem? You already wrote process .env.DATABASE_URL in your code. Why write it again in a schema? The Solution npx dotenv - audit -- ask That's it. One command. It: Scans your .js, .ts, .jsx, .tsx, .vue, .svelte files Finds every process.env.XXXX automatically Shows what's missing with exact

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles