@jswork/dotenv-local-first
v1.0.4
Published
Dotenv local first cli.
Readme
dotenv-local-first
Dotenv local first cli.
Installation
yarn add --dev @jswork/dotenv-local-firstUsage
This CLI tool loads environment variables from .env* files with the following priority (later files override earlier ones):
.env.env.${NODE_ENV}(e.g.,.env.development,.env.production).env.local.env.${NODE_ENV}.local(e.g.,.env.development.local)
Basic usage
# Just load and display environment variables
dotenv-local-first
# Run a script with loaded environment variables
dotenv-local-first your-script.js
# Run with verbose logging
dotenv-local-first -v your-script.jsExample
Create your environment files:
# .env (base configuration)
DATABASE_NAME=myapp_db
DATABASE_USER=root
DATABASE_PORT=3306
DATABASE_PASS=secret123
# .env.development (development overrides)
DATABASE_NAME=myapp_dev_db
DATABASE_PORT=3307
DATABASE_PASS=dev_secret
# .env.local (local overrides - should not be committed)
DATABASE_PASS=local_override_password
DATABASE_USER=local_userThen run:
NODE_ENV=development dotenv-local-firstThis will load variables with the priority: .env → .env.development → .env.local → .env.development.local
Development
bun create cli/dotenv-local-first --no-git --no-install