Skip to content

Latest commit

 

History

81 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

envk

This package lets you autoload your environment variables from your .env file, no code changes required.
Similar to dotenv, but with zero dependencies and less verbose.

Easy as:

pnpm add envk
node -r envk index.js

Features:

  • auto-detect of .env.<NODE_ENV> or .env file
  • support for custom .env filename with ENVK environment variable
  • support for variable expansion
  • support for single quotes
  • support for double quotes
  • support for empty lines
  • support for multiline quoting with double quotes "SECRET=hello\nworld"
  • support for line comments starting with #

You can see what's happening by inspecting index.js.

Nothing more, nothing less.

Usage

Load envs from .env:

node -r envk index.js

Load envs from .env.production file if present, otherwise .env:

NODE_ENV=production node -r envk index.js

Load envs from specific file:

ENVK=file.env node -r envk index.js

Log to console imported variables:

ENVK_DEBUG=1 node -r envk index.js

You can also use envk programmatically:

// autoload
import "envk";

// or

// fn to call
import envk from "envk/fn";
envk('<path>');

Development

Setup:

fnm install
npm install -g corepack
corepack enable
corepack install
pnpm install
pnpm test

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages