env-check-ts
v1.0.3
Published
CLI tool to validate .env files and generate .env.example using schema defined with Zod in TypeScript.
Maintainers
Readme
env-check-ts
A TypeScript CLI tool to validate
.envfiles and auto-generate.env.exampleusing a Zod schema.
Why env-check-ts?
Managing environment variables is risky without validation.
This tool helps you:
- Validate all required environment variables before your app runs
- Check variable types and allowed values using Zod
- Auto-generate a clean
.env.examplefor your team - Prevent runtime bugs due to misconfigured or missing envs
Installation
Install globally:
npm install -g env-check-tsor use directly without installing:
npx env-check-ts validateFeatures
CLI commands: validate, generate
Type-safe validation via Zod
Auto-generates .env.example from schema
Zero-config, works out-of-the-box
Easily extendable for teams and CI/CD
Usage
1)Define Schema
Create src/schema.ts:
import { z } from "zod";
export const envSchema = z.object({
NODE_ENV: z.enum(["development", "production", "test"]),
PORT: z.string(),
DATABASE_URL: z.string().url(),
});2)Validate .env
env-check-ts validateExample output:
❌ Environment validation failed:
• NODE_ENV: Invalid enum value. Expected 'development' | 'production' | 'test', received 'dev'
• DATABASE_URL: Required3)Generate .env.example
env-check-ts generateExample output:
env
NODE_ENV=development
PORT=
DATABASE_URL=Contributing
The project welcomes all constructive contributions. Contributions take many forms, from code for bug fixes and enhancements, to additions and fixes to documentation, additional tests, and many more!
git clone https://github.com/your-username/env-check-ts
cd env-check-tsnpm install
npm run devLicense
MIT
