env-check-lite
v1.0.3
Published
Lightweight runtime environment variable validator
Maintainers
Readme
env-check
A lightweight Node.js/TypeScript package to validate environment variables at runtime.
Features
- ✅ Check required environment variables at startup
- ✅ Zero dependencies → super lightweight
- ✅ TypeScript-first with full typings
- ✅ Works with Node.js, NestJS, Express, Next.js, etc.
Installation
npm install @jaynil001/env-checkor with yarn:
yarn add @jaynil001/env-checkUsage
1. Import
import { checkEnv } from "@jaynil001/env-check";2. validate required env variables
checkEnv(["DB_HOST", "DB_USER", "DB_PASS"]);- if missing
❌ Missing required environment variables: DB_PASS- if all present
✅ All required environment variables are set!Example Use Case
Suppose you have a .env file like:
DB_HOST=localhost
DB_USER=admin
DB_PASS=secretYou can validate these variables at the start of your application:
import { checkEnv } from "@jaynil001/env-check";
checkEnv(["DB_HOST", "DB_USER", "DB_PASS"]);If any variable is missing, the process will exit with an error message.
If all are present, your app continues to run as expected.
