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

sebenv

v0.0.6

Published

CLI tool to ensure environment variables are set.

Readme

Better ENV management

SebEnv

SebEnv is a CLI tool that helps ensure your environment variables are properly set up for your Node.js projects. It allows you to specify required environment variables in your package.json file, add new variables, sync variables from your .env file, scan source code to find environment variables, and automatically create or update the .env file if variables are missing.

Features

  • Check Environment Variables: Ensures that all specified environment variables are set.
  • Add Variables: Add new environment variables to the envCheck section in package.json.
  • Sync Variables: Syncs environment variables from your .env file to the envCheck section in package.json.
  • Scan Source Code: Scans project files recursively to detect process.env usages and adds them interactively.
  • Interactive CLI: Prompts you to input missing environment variables and updates the .env file automatically.

Installation

Install SebEnv globally using npm:

npm install -g sebenv

Usage

1. Checking Environment Variables

To check if all required environment variables are set, simply run:

SebEnv

If any variables are missing, SebEnv will prompt you to enter the values and will update your .env file automatically.

If the project doesn't have an envCheck list configured in its package.json, SebEnv will offer to scan the project automatically to initialize it.

2. Adding New Variables

To add new environment variables to the envCheck section in package.json, use:

SebEnv --add VAR_NAME1 VAR_NAME2

This will add VAR_NAME1 and VAR_NAME2 to the list of required environment variables in package.json. The tool ensures that no duplicates are added.

3. Syncing Variables from .env

To sync all variables from your .env file to the envCheck section in package.json, use:

SebEnv --sync

This command will read all the environment variables from your .env file and add them to the envCheck section in package.json, ensuring that there are no duplicates.

4. Scanning Source Code for Environment Variables

To automatically scan your source code for any used environment variables, run:

SebEnv --scan

(or the alias SebEnv --find)

This scans all JS, JSX, TS, TSX, MJS, CJS, Vue, and Svelte files (recursively scanning src/ if it exists, or the project root while ignoring common directories like node_modules and dist). It detects dot notation, bracket notation, and destructuring from process.env. It then presents an interactive checklist for you to select which detected variables to add to your package.json config.

Excluding specific folders

You can exclude specific folders from the scan by using the --exclude option followed by a comma-separated list of folder names:

SebEnv --scan --exclude tests,temp

You can target a specific environment by using the --env (or -e) option:

SebEnv --env prod
SebEnv --scan --env dev
SebEnv --add API_KEY --env staging

If --env is omitted, SebEnv checks the environment matching the NODE_ENV system variable, or falls back to the default environment.

Configuration

Add a section in your package.json file named envCheck where you define configurations and map environments.

  • Upgrading from legacy formats: If you have an existing array-based config, a flat object config, or the deprecated envCheckExclude array, SebEnv will automatically migrate them to the new nested format in-place on the very first run.
  • Variable Options:
    • To require a variable: Set its value to { "required": true } or a boolean true.
    • To mark a variable as optional (which will be skipped during verification checks): Set its value to { "required": false } or a boolean false.

Example package.json Configuration

{
  "name": "my-project",
  "version": "1.0.0",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {},
  "envCheck": {
    "scan": {
      "excludeDirectories": [
        "tests",
        "scripts",
        "legacy-code"
      ]
    },
    "environments": {
      "default": {
        "API_KEY": { "required": true },
        "PORT": false
      },
      "prod": {
        "API_KEY": { "required": true },
        "DB_HOST": { "required": true }
      }
    }
  }
}

Runtime Validation

You can also import SebEnv directly into your application to validate environment variables synchronously at startup. If any required variables for the target environment (or NODE_ENV) are missing, it will throw a descriptive error preventing your application from running in an invalid state.

import { validateEnv } from 'sebenv';

// Validates against NODE_ENV (or "default")
validateEnv();

// Or validate a specific environment explicitly
validateEnv('prod');

License

This project is licensed under the AGPL-3.0 License - see the LICENSE file for details.