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

assenvle

v1.0.0

Published

Merge environment variables for a given mode into a single file.

Downloads

12

Readme

assenvle-logo-light assenvle-logo-dark

assenvle merges environment variables for a given mode into a single file.

Quick Start

  1. Install assenvle.
npm install --save-dev assenvle
  1. Put your .env* files in a (root directory)/env directory.
(root directory)
├── env
│   ├── .env
│   ├── .env.local
│   ├── .env.development
│   ├── .env.development.local
│   ├── .env.staging
│   ├── .env.staging.local
│   ├── .env.production
│   ├── .env.production.local
:   :
  1. Run the following command in the root directory. assenvle merges your .env* files for a given mode into (root directory)/.env.local.
npx assenvle --mode development

Configuration

Command Line Arguments

  • -m, --mode <mode>: Specifies the .env* files to read. (development, staging, production, etc.)

[!Note] assenvle reads your .env* files with the following priority, which is the same order as Next.js.

  1. .env.{mode}.local
  2. .env.local
  3. .env.{mode}
  4. .env
  • -w, --watch: If this option is set to true, assenvle regenerates the output file on changes to the input .env* files. (default: false)
  • -h, --help: Displays help for command.

Configuration File

  • Although you can use assenvle without any configuration files, you can also customize the behavior with assenvle.config.{ts,mjs}.
  • Create assenvle.config.ts or assenvle.config.mjs in the root directory and default export your configuration.
  • options
    • envDir: string: Path of the directory where your .env* files are placed. (default: env)
    • outputFile: string: Path of the output file. (default: .env.local)
    • validateEnv: (env: Record<string, string>) => void: (optional) If provided, assenvle uses this function to validate the merged .env files. assenvle cancels generating the output when this validation function throws an error.
  • configuration example
import { defineConfig } from "assenvle";

export default defineConfig({
  envDir: "configs/env",
  outputFile: ".env",
  validateEnv: (env) => {
    if (!("SAMPLE_URL" in env)) {
      throw new Error("SAMPLE_URL is not defined.");
    }

    if (!env.SAMPLE_URL.startsWith("http")) {
      throw new Error("Invalid URL.");
    }
  }
});

[!Caution] assenvle uses "Type Stripping" of Node.js to read assenvle.config.ts. If you want to use assenvle.config.ts, your Node.js version should be 23.6.0 or higher. (You can also use Node.js 22.6.0 or higher with --experimental-strip-types option.)

Integration with Next.js

Although you can integrate assenvle with any framework of your choice, it is designed to be used primarily in combination with Next.js. We recommend to modify your npm scripts as follows (we are using concurrently in dev command):

{
  "scripts": {
-   "dev": "next dev",
+   "dev": "concurrently -k 'assenvle -w -m $npm_config_mode' 'next dev'",
+   "dev:development": "npm run dev -mode=development",
+   "dev:staging": "npm run dev -mode=staging",
+   "dev:production": "npm run dev -mode=production",
-   "build": "next build",
+   "build": "assenvle -m $npm_config_mode && next build",
+   "build:development": "npm run build -mode=development",
+   "build:staging": "npm run build -mode=staging",
+   "build:production": "npm run build -mode=production",
  },
}

In this way, when you edit the input .env* file, assenvle automatically regenerates the output .env.local, and then Next.js detects this and automatically restarts the development server. If you define validateEnv function, the dev process will terminate on validation failure.