# @reactmode/env-check
Validate your `.env` file against `.env.example` before runtime. Catch missing or extra environment variables early — especially useful for Next.js, Vite, and Node.js projects.
## 📦 Installation
### Using npx (recommended)
```bash
npx @reactmode/env-check
```npm install -g @reactmode/env-checkThen run:
env-checkCompares:
.env.env.example
And reports:
- ❌ Missing variables (defined in
.env.examplebut not in.env) ⚠️ Extra variables (defined in.envbut not in.env.example)- ✅ Valid environment when both match
The command exits with:
0→ No issues found1→ Mismatch detected
This makes it suitable for CI pipelines.
Your project should contain:
.env
.env.example
VITE_API_URL=
VITE_CLIENT_URL=
VITE_LUMI_API_KEY=
VITE_API_URL=https://api.example.com
VITE_CLIENT_URL=http://localhost:5173
VITE_LUMI_API_KEY=abc123
✅ Environment variables are valid
Missing variables:
- VITE_API_URL
Extra variables not in .env.example:
- VITE_UNUSED_VAR
Environment issues are often discovered at runtime:
- Undefined API URLs
- Missing client URLs
- Incorrect deployment configuration
- Broken production builds
This tool shifts that validation to development time.
Useful for:
- Next.js projects
- Vite projects
- Node APIs
- CI/CD pipelines
- Team onboarding
- Reads
.env.example - Reads
.env - Parses both using
dotenv - Compares key existence (not value truthiness)
- Reports structural mismatches
Empty values like:
API_KEY=
are treated as valid if the key exists.
| Exit Code | Meaning |
|---|---|
| 0 | Environment files match |
| 1 | Missing or extra variables detected |
Example CI usage:
env-check && echo "Environment valid"Planned improvements:
--fixflag to auto-add missing keys- Custom file path support
- Strict mode
- Sorting suggestions
- Formatting validation
Built by ReactMode.