slopenv-expand
v1.0.1
Published
Sensible environment variable loading for monorepos with variables expansion.
Maintainers
Readme
slopenv-expand
Sensible environment variable loading for monorepos with variables expansion.
Overview
slopenv-expand is a CLI tool that combines the power of slopenv for intelligent environment variable loading in monorepos with dotenv-expand for variable expansion support.
It provides a simple way to load environment variables from multiple .env files following a sensible precedence order, expand variables within those files, and then execute any command with the loaded environment.
Features
- Monorepo-aware: Loads environment variables from multiple
.envfiles following a sensible precedence order - Variable expansion: Supports expanding variables within
.envfiles (e.g.,DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:5432/mydb) - Simple CLI: Run any command with pre-loaded environment variables
- Zero configuration: Works out of the box with sensible defaults
- TypeScript: Written in TypeScript with full type safety
Installation
npm install -g slopenv-expandOr use with npx:
npx slopenv-expand <command>Usage
slopenv-expand <command> [args]Examples
Run a Node.js script with environment variables loaded:
slopenv-expand node server.jsRun npm scripts with environment variables:
slopenv-expand npm run devRun any command with environment variables:
slopenv-expand python script.py
slopenv-expand go run main.go
slopenv-expand docker-compose upHow It Works
Loads environment variables using
slopenvwhich follows this precedence order:- System environment variables (highest priority)
.env.local(for local overrides).env.development,.env.test,.env.production(based onNODE_ENV).env(base file)
Expands variables using
dotenv-expand, allowing you to reference other variables:DB_USER=admin DB_PASSWORD=secret DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:5432/mydbExecutes your command with the loaded environment variables
Environment File Examples
Basic .env file
PORT=3000
DATABASE_URL=postgres://localhost:5432/mydb
API_KEY=your-api-key-hereWith variable expansion
DB_HOST=localhost
DB_PORT=5432
DB_NAME=mydb
DATABASE_URL=postgres://${DB_HOST}:${DB_PORT}/${DB_NAME}Environment-specific files
.env.development- Development-specific variables.env.test- Test-specific variables.env.production- Production-specific variables.env.local- Local overrides (gitignored by default)
Comparison with Other Tools
| Feature | slopenv-expand | dotenv | dotenv-expand | slopenv | | -------------------------- | -------------- | ------ | ------------- | ------- | | Monorepo support | ✅ | ❌ | ❌ | ✅ | | Variable expansion | ✅ | ❌ | ✅ | ❌ | | Environment-specific files | ✅ | ✅ | ❌ | ✅ | | CLI interface | ✅ | ❌ | ❌ | ✅ | | Zero configuration | ✅ | ❌ | ❌ | ✅ |
Development
Prerequisites
- Node.js >= 20
- npm
Setup
git clone https://github.com/shurizzle/slopenv-expand.git
cd slopenv-expand
npm installBuild
npm run buildDevelopment mode
npm run devCode Quality
npm run check # Run format, lint, and type checks
npm run format # Format code
npm run lint # Lint code
npm run typecheck # Type checkLicense
MIT © 2026 shurizzle
