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 🙏

© 2025 – Pkg Stats / Ryan Hefner

obelisq

v0.2.0

Published

Load environment variables from `.env` into `NodeJS.ProcessEnv`.

Readme

Obelisq 🔺

Load environment variables from .env into NodeJS.ProcessEnv.

Install

pnpm add obelisq

Usage

Create a .env file in the root directory of your project, e.g.:

SUPER_SECRET_KEY=your_secret_key
API_VERSION=2

In the entrypoint to your app (e.g. index.ts), call setup to load your .env into Node's process.env:

// index.ts
import { setup } from "obelisq";

await setup({
  files: [".env"], // Mandatory. No assumptions are made about the file name. Add as many as you want.
});

You can also run $ obelisq -f <path> -s "<script>" to load the environment variables from the file at path into process.env for another Node script. Say you have a file log-env.js which simply executes console.log(process.env). You can inject the values from your environment file into process.env by running the following command:

$ obelisq -f .env -s "node log-env.js"

The output should contain:

$ obelisq -f .env -s "node log-env.js"

{
  // ...
  SUPER_SECRET_KEY: 'your_secret_key',
  API_VERSION: '2'
}

Type-safety

You can generate a library which provides minimal type-safety when accessing the environment variables.

obelisq -f .env generate [-o <string>]

This will output obelisq.ts (unless specified differently with -o — "output path") which exports environment, a function which takes a single argument of type TObelisqEnvironmentKeys. What is TObelisqEnvironmentKeys? It's a type that extends a Record where the keys are the keys of your environment file and the values are the (assumed) type of the value, e.g.:

type TObelisqEnvironmentKeys = {
  SUPER_SECRET_KEY: string;
  API_VERSION: number;
};

Variable expansion

Variable expansion works out of the box without any additional packages or configuration steps. If your environment looks like this:

SUPER_SECRET_KEY=your_secret_key
API_VERSION=2${SUPER_SECRET_KEY}

Running $ obelisq -f .env will add the following to process.env:

SUPER_SECRET_KEY: 'your_secret_key',
API_VERSION: '2your_secret_key'

Note that it's advisable to run $ obelisq generate every time you change your .env as expansion may change the value's assumed type.

Multiple files

You can load multiple files by passing an array of file names to the setup function. The files are loaded in the order they are passed, so if a variable is defined in multiple files, the last one will take precedence.

Say you have two files:

# .env
SUPER_SECRET_KEY=your_secret_key
# .env.local
SUPER_SECRET_KEY=your_local_secret_key

If you call setup like this:

await setup({
  files: [".env", ".env.local"],
});

The value of SUPER_SECRET_KEY in process.env will be your_local_secret_key.