npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@elattariyassine/envcheck

v1.1.3

Published

A powerful Node.js CLI tool for validating, managing, and fixing environment variables

Readme

envcheck

Alt text

npm package Build Status Downloads Issues Code Coverage Semantic Release

A CLI tool that validates environment variables against .env.example and helps fix any issues.

Features

  • 🔍 Validate environment variables against .env.example
  • 🛠️ Interactive mode to fix missing or invalid variables
  • 📝 Support for different variable types (string, number, boolean)
  • 🎨 Colorized output for better readability
  • 🔒 Secure handling of sensitive information
  • 🔄 Custom file paths for .env and .env.example
  • 📊 Detailed validation reports
  • 📋 Preserves file formatting and comments when updating files

Installation

You can use EnvCheck in two ways:

1. Using npx (Recommended for one-time use)

npx @elattariyassine/envcheck init
npx @elattariyassine/envcheck validate
npx @elattariyassine/envcheck fix

2. Global Installation

npm install -g @elattariyassine/envcheck

After global installation, you can use the commands directly:

envcheck init
envcheck validate
envcheck fix

Local Development Setup

To set up the project locally for development:

  1. Clone the repository:
git clone https://github.com/elattariyassine/envcheck.git
cd envcheck
  1. Install dependencies:
npm install
  1. Build the project:
npm run build
  1. Link the package locally for testing:
npm link

Now you can use envcheck commands globally while developing.

Available Scripts

  • npm run build - Compiles TypeScript code to JavaScript
  • npm test - Runs Jest tests
  • npm run lint - Runs ESLint to check code quality
  • npm run format - Formats code using Prettier

Development Workflow

  1. Make your changes in the src directory
  2. Run tests to ensure everything works: npm test
  3. Build the project: npm run build
  4. Test your changes using the CLI commands

To unlink the package when you're done:

npm unlink

Usage

Initialize Environment Files

npx @elattariyassine/envcheck init

This command will:

  1. Create a new .env.example file with common environment variables
  2. Include examples for different types of variables (string, number, boolean)
  3. Add helpful comments for each section
  4. Maintain proper formatting and structure

Validate Environment Variables

npx @elattariyassine/envcheck validate

This command will:

  1. Read your .env and .env.example files
  2. Validate all required variables
  3. Check variable types and formats
  4. Display any errors or warnings
  5. Preserve all existing comments and formatting

Fix Environment Variables

npx @elattariyassine/envcheck fix

This command will:

  1. Check for missing or invalid variables
  2. Prompt you to enter values for missing variables (in interactive mode)
  3. Update your .env file with the new values
  4. Maintain all existing comments, section headers, and formatting
  5. Keep the file structure clean and organized

Command Options

# Show version
npx @elattariyassine/envcheck -V
npx @elattariyassine/envcheck --version

# Fix command options
npx @elattariyassine/envcheck fix --file custom.env           # Use custom .env file
npx @elattariyassine/envcheck fix --example custom.example    # Use custom .env.example file
npx @elattariyassine/envcheck fix --no-interactive           # Disable interactive mode

# Show help for any command
npx @elattariyassine/envcheck --help
npx @elattariyassine/envcheck validate --help
npx @elattariyassine/envcheck fix --help

Example Files

.env.example

# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=myapp
DB_USER=postgres
DB_PASSWORD=your_password

# API Configuration
API_URL=https://api.example.com
API_KEY=your_api_key
API_TIMEOUT=5000

# Feature Flags
DEBUG_MODE=false
ENABLE_CACHE=true

# Email Configuration
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=your_email
SMTP_PASS=your_password

# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=

# Logging Configuration
LOG_LEVEL=info
LOG_FILE=app.log

# Security Configuration
JWT_SECRET=your_jwt_secret
SESSION_TIMEOUT=3600

.env (with some invalid values)

# Database Configuration
DB_HOST=localhost
DB_PORT=not-a-number
DB_NAME=myapp
DB_USER=postgres
DB_PASSWORD=secret123

# API Configuration
API_URL=not-a-url
API_KEY=abc123
API_TIMEOUT=5000

# Feature Flags
DEBUG_MODE=not-a-boolean
ENABLE_CACHE=true

# Email Configuration
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=your_email
SMTP_PASS=your_password

# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=

# Logging Configuration
LOG_LEVEL=info
LOG_FILE=app.log

# Security Configuration
JWT_SECRET=your_jwt_secret
SESSION_TIMEOUT=3600

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

TODO

  • [x] Create basic CLI structure
  • [x] Implement environment variable validation
  • [x] Add interactive mode for fixing variables
  • [x] Add support for different variable types
  • [x] Implement file formatting preservation
  • [x] Add GitHub Actions workflows
  • [x] Set up semantic-release
  • [x] Add comprehensive tests
  • [x] Add version command
  • [x] Update license to ISC
  • [x] Update package name to be scoped
  • [ ] Add usage examples in README

License

ISC