@tqman/env
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

@tqman/env

A thin wrapper around dotenv for providing consistent experience with loading environment variables across different runtimes.

📦 Install

Install using npm

npm install dotenv@latest @tqman/env@latest

Install using bun

bun install dotenv@latest @tqman/env@latest

⚙️ Loading Strategy

Environment variables are loaded in the following order:

  • .env
  • .env.{mode} (mode is NODE_ENV lowercased, default is development)
  • .env.local

Strategy is a mix of both bun, vite.

[!NOTE]
Difference from Bun's strategy - bun only supports .env.{mode} when mode is production, development or test. Issue: https://github.com/oven-sh/bun/issues/9090

[!NOTE]
Difference from Vite's strategy - .env.{mode}.local is loaded by default in vite, but not by this library.

👨‍💻 Usage

As a side effect import

import "@tqman/env/load";

As a function call

import { load } from "@tqman/env";

load();

Package Sidebar

Install

npm i @tqman/env

Weekly Downloads

1

Version

1.1.1

License

BSD-2-Clause

Unpacked Size

4.21 kB

Total Files

7

Last publish

Collaborators

  • tanishqmanuja