π Getting Started
Welcome to Env Checkup β a simple and powerful CLI tool to generate, validate, and enforce consistency in your .env files.
This guide will help you install, configure, and run your first validation in under 2 minutes.
π§© Prerequisitesβ
Before getting started, make sure you have:
- Node.js β₯ 18
- npm or yarn installed
- A project containing one or more
.envfiles
Example project structure:
my-app/
β£ .env
β£ .env.example
β£ src/
β β index.ts
β package.json
βοΈ Installationβ
You can install Env Checkup globally (to use the CLI anywhere) or locally (per project).
πͺ΄ Global Installationβ
npm install -g env-checkup
Once installed, you can run it directly:
env-checkup --help
π± Local Installation (Recommended)β
npm install env-checkup --save-dev
Then add it to your package.json scripts:
"scripts": {
"env:init": "env-checkup init",
"env:validate": "env-checkup validate"
}
Now you can run:
npm run env:init
npm run env:validate
ποΈ Step 1 β Initialize Your Schemaβ
Run the init command to create a schema file interactively.
npx env-checkup init
Youβll be prompted for each environment variable and its type:
? Enter variable name: DATABASE_URL
? Type of value (string/number/boolean): string
? Enter variable name: PORT
? Type of value: number
? Add another variable? (y/n): n
Env Checkup will generate a .env.schema.json file in your project root.
Example:
{
"DATABASE_URL": "string",
"PORT": "number",
"JWT_SECRET": "string"
}
π Step 2 β Validate Your .env Filesβ
Run the validate command to check your .env files against the schema.
npx env-checkup validate
Example output:
β
Valid variable: PORT = 3000
β οΈ Missing variable: JWT_SECRET
β Invalid type: TIMEOUT (expected number, got string)
βοΈ Step 3 β Add to CI/CDβ
Integrate Env Checkup into your CI pipeline to ensure every deployment has valid environment variables.
Example: GitHub Actions
- name: Validate Environment
run: npx env-checkup validate --strict
If validation fails, the build will stop β preventing incomplete deployments.
π§© Step 4 β Custom Configuration (Optional)β
You can configure Env Checkup globally via .envcheckuprc.json in your project root.
Example configuration:
{
"schemaPath": "./.env.schema.json",
"envDir": "./",
"strict": true,
"ignore": ["NODE_ENV"]
}
Alternatively, pass options through CLI flags:
env-checkup validate --schema ./.env.schema.json --strict
π§ Example Workflowβ
A complete example from start to finish:
# Step 1 β Create schema
npx env-checkup init
# Step 2 β Validate .env files
npx env-checkup validate
# Step 3 β Enforce in CI/CD
npx env-checkup validate --strict
Result:
β
All environment variables validated successfully!
π§° Example npm Scriptsβ
Add reusable scripts for your team:
"scripts": {
"env:init": "env-checkup init",
"env:check": "env-checkup validate --strict"
}
Then run:
npm run env:init
npm run env:check
π§© Step 5 β Supported .env Filesβ
Env Checkup automatically detects and validates the following:
.env
.env.local
.env.example
.env.development
.env.production
.env.test
.env.bat
You donβt need to configure this β it just works out of the box.
π§Ύ Example Project Validation Outputβ
Hereβs what a real project validation looks like:
$ npx env-checkup validate
Checking .env and .env.local...
β
PORT = 3000
β
DATABASE_URL = postgresql://localhost/db
β οΈ Missing variable: JWT_SECRET
β Invalid type: DEBUG_MODE (expected boolean, got string)
Summary:
3/5 variables valid
2 issues detected
π‘ Tipsβ
- Always include your
.env.schema.jsonin version control - Add
.envto.gitignore - Run validation before deploying your app
- Share the schema file with your teammates
π§ Next Stepsβ
- Learn more about Configuration
- Explore available CLI Commands
- Check out FAQ for common troubleshooting
π§βπ» Example for Next.js Usersβ
If youβre using Next.js, you can validate environment variables before starting your dev server:
"scripts": {
"dev": "env-checkup validate --strict && next dev"
}
This ensures the app only runs if .env is valid.
π§© Summaryβ
| Step | Command | Description |
|---|---|---|
| 1οΈβ£ | npx env-checkup init | Generate schema interactively |
| 2οΈβ£ | npx env-checkup validate | Validate .env files |
| 3οΈβ£ | --strict | Fail build if variables are missing |
| 4οΈβ£ | --schema | Custom schema file path |
| 5οΈβ£ | --dir | Validate from specific directory |
π Conclusionβ
π Youβve successfully set up Env Checkup!
You can now ensure every developer and every environment stays consistent β no more βmissing .env variableβ surprises.
Next: Configuration β