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

envi-switch

v1.0.1

Published

Universal .env file manager — switch, diff, and validate environments with one command

Readme


The Problem

  • You juggle .env.development, .env.staging, .env.production by hand-copying files.
  • You have no idea which variables are missing from which environment until something crashes.
  • Comparing two .env files means squinting at two tabs side by side.

The Solution

  • One command to switch your active .env — no copy-pasting, no mistakes.
  • Instant validation across all environments — catch missing keys before they hit production.
  • Side-by-side diff with masked values — see exactly what differs without leaking secrets.

Quick Start

npm install -g envi-switch

cd your-project
envi init
envi use development

That's it. Your .env is now managed.

Commands

envi init

Scans your project for .env.* files and initializes envi.

$ envi init

  Found 3 environment files:
    .env.development
    .env.staging
    .env.production

  ✔ envi initialized. Use "envi use <env>" to switch environments.

envi use <environment>

Switch the active .env to a specific environment. Backs up the current .env automatically.

$ envi use production
  ✔ Switched from development → production
  ℹ Previous .env backed up to .env.backup

Flags:

  • -f, --force — Discard unsaved changes without prompting.

envi ls

List all available environments and highlight the active one.

$ envi ls

  ●  development  (12 vars)
  ○  staging      (12 vars)
  ○  production   (11 vars)

envi diff [env1] [env2]

Compare two environments side by side. Values are masked by default.

$ envi diff development production

  Comparing development ↔ production

  ┌──────────────┬─────────────┬──────────────┐
  │ Variable     │ development │ production   │
  ├──────────────┼─────────────┼──────────────┤
  │ DATABASE_URL │ loc•••••••• │ rds•••••••   │
  │ API_KEY      │ dev•••••••• │ pk_•••••••   │
  │ DEBUG        │ true        │ ✗ missing    │
  └──────────────┴─────────────┴──────────────┘

  Summary: 2 different, 1 only in development, 0 only in production

Run with zero arguments to get a summary comparing every environment against the active one:

$ envi diff
  Comparing against active: development

  staging:    1 different, 0 missing, 0 extra
  production: 2 different, 1 missing, 0 extra

Flags:

  • --show-values — Show actual values instead of masking.

envi validate

Check all environments for missing or inconsistent variables. Returns exit code 1 on failure — perfect for CI.

$ envi validate
  ✔ development: all 12 variables present
  ✔ staging: all 12 variables present
  ⚠ production: missing 1 variables
    - DEBUG

$ echo $?
1

Flags:

  • --strict — Also flag empty values.
  • --env <name> — Validate a single environment.

envi create <name>

Create a new environment by cloning an existing one.

$ envi create qa --from staging
  ✔ Created .env.qa

Flags:

  • --from <env> — Copy from a specific environment (defaults to the active one).
  • --empty — Copy keys only, leave values blank.

envi save

Save changes made to .env back to the source environment file.

$ envi save
  ✔ Changes saved to .env.development
    + 1 added
    ~ 2 changed

envi export <environment>

Export an environment in different formats. Output goes to stdout so you can pipe it.

$ envi export production --format json
{
  "DATABASE_URL": "postgres://...",
  "API_KEY": "pk_live_..."
}

$ envi export staging --format shell
export DATABASE_URL="postgres://..."
export API_KEY="sk_test_..."

$ envi export production --format docker > .env.docker

Flags:

  • --format <format> — Output format: dotenv (default), json, shell, docker, yaml.
  • --mask — Mask values for safe review or sharing.
  • --output <file> — Write to a file instead of stdout.

Comparison

| Feature | envi | direnv | dotenv-vault | Manual | |---------|------|--------|-------------|--------| | Switch environments | one command | - | yes | manual cp | | Diff environments | yes | - | - | - | | Validate all envs | yes | - | - | - | | Free & local | yes | yes | paid | yes | | Zero config | yes | .envrc needed | account needed | yes | | Cross-platform | yes | Unix only | yes | yes |

How It Works

When you run envi init, envi scans for .env.* files and creates a small .envi state file (JSON) that tracks:

  • Which environments exist
  • Which one is currently active
  • When the last switch happened

When you envi use staging, envi:

  1. Backs up your current .env to .env.backup
  2. Copies .env.staging to .env
  3. Updates .envi state

Your environment files (.env.development, .env.production, etc.) are never modified — they remain your source of truth. Only .env changes.

The .envi and .env.backup files are automatically added to .gitignore.

CI/CD Integration

Add envi validate to your CI pipeline to catch missing environment variables before deployment:

# .github/workflows/ci.yml
name: CI
on: [push, pull_request]

jobs:
  validate-env:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - run: npx envi-switch init
      - run: npx envi-switch validate --strict

If any environment is missing variables, the step fails and your PR gets a red check.

Contributing

Contributions are welcome! Here's how to get started:

git clone https://github.com/sup3x/envi.git
cd envi
npm install
npm test        # Run the test suite
npm run build   # Build for production

Development workflow:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feat/your-feature
  3. Make your changes and add tests
  4. Run npm test to ensure all tests pass
  5. Submit a pull request

Please make sure all existing tests pass and new features include appropriate test coverage.

License

MIT -- Kerim Gulen