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

envf

v3.1.1

Published

A simple easy modular isolated module type env manager to inject env keys to process.env

Downloads

20

Readme

envf — Minimal, Smart, Zero-Bullshit Environment Loader

A lightweight .env loader designed for real-world Node.js apps — automatic environment detection, layered env loading, optional overrides, and a clean API.

No dependencies. No magic. Just predictable behavior.


🚀 Features

  • Auto-loads env files based on environment mode:

    • .env.development.local
    • .env.local
    • .env.development
    • .env
  • Supports manual single-file loading via load()

  • Injects values directly into process.env

  • Override behavior configurable (override: true | false)

  • Zero surprises path resolution (cwd > fallback-to-module)

  • Debug helpers (see(), keys())


📦 Installation

npm install envf

or

pnpm add envf

🎯 Quick Usage

Auto mode

(recommended — handles NODE_ENV logic)

import envf from "envf";

envf.autoLoad();

console.log(process.env.PORT);
console.log(process.env.DB_URL);

Works immediately with zero configuration.


Manual load (single file)

import envf from "envf";

envf.load(".env"); // resolves path automatically

Load an absolute file path

envf.pathLoad("/etc/app/secrets.env");

Inject manually

envf.setKey("PORT"); // one
envf.setKeys(["PORT", "DB_URL"]); // many

With override:

envf.setKeys(["PORT", "DB_URL"], { override: true });

Get values

const db = envf.getKey("DB_URL");

Debugging

envf.keys(); // show injected keys
envf.see();  // show loaded files

🧠 Environment Loading Priority

When calling autoLoad(), files are loaded in this order (first found → overrides later ones):

.env.<NODE_ENV>.local
.env.local
.env.<NODE_ENV>
.env

For example: running with:

NODE_ENV=production

Load order becomes:

.env.production.local
.env.local
.env.production
.env

🛠 API Summary

| Method | Purpose | | ------------------------- | ------------------------------------ | | load(file) | Load a specific env file | | autoLoad(options?) | Auto load layered env files | | pathLoad(path) | Load env from an explicit path | | setKey(key) | Inject a single key into process.env | | setKeys(keys, options?) | Bulk inject multiple keys | | getKey(key) | Retrieve a value | | keys() | Show injected keys | | see() | Show loaded files |


🧭 Changelog

v1.x.x — Initial Implementation

  • Basic .env loading
  • Basic parsing and manual injection
  • No override logic
  • No layering or environment detection

v2.x.x — Layered Environment & Auto Loading

  • Added autoLoad() with multi-file loading support
  • Added path resolution (cwd → fallback)
  • Added automatic injection behavior
  • Added multiple env file support (.env.local, .env.NODE_ENV, etc.)

v3.x.x — Configurable Injection & Better DX

  • Added setKeys() with optional { override: boolean }
  • Added getKey(), keys(), and see() for debugging and introspection
  • Improved logging accuracy
  • Added validation for invalid key names
  • Stabilized module export structure and path resolution logic

v3.1.x — Refinement & Stability

  • API consistency cleanup
  • Logging and behavior now fully deterministic
  • Internal path resolution improvements
  • Polished for npm release

📌 License

LICENSE — build cool shit, don’t use it for malware, and don’t pretend you wrote it.


💬 Contributing

PRs welcome — just don’t break the API and keep it clean.