1.1.1 • Published 1 year ago
@tqman/env v1.1.1
@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();