bunjs-env
v1.0.0
Published
Cross-platform environment variable setter for Bun.js
Maintainers
Readme
bunjs-env
Cross-platform environment variable setter optimized for Bun.js.
Installation
# Install globally
bun install -g bunjs-env
# Or use with bunx (no installation required)
bunx bunjs-env NODE_ENV=production bun run startUsage
Set environment variables before running commands, works consistently across all platforms:
bunjs-env NODE_ENV=production bun run start
bunjs-env DEBUG=true API_KEY=secret bun run dev
bunjs-env NODE_ENV=test bun testMultiple Environment Variables
bunjs-env NODE_ENV=production PORT=3000 DEBUG=false bun run startDebug Mode
See exactly what environment variables are set and which command is executed:
bunjs-env --debug NODE_ENV=test bun run testWhy bunjs-env?
Built specifically for the Bun ecosystem with native performance optimizations. Inspired by the excellent cross-env but optimized for Bun's unique capabilities:
- Zero dependencies - Lightweight and secure
- Native Bun integration - Uses Bun's built-in shell capabilities
- TypeScript ready - Works seamlessly with TypeScript projects
- Fast execution - Leverages Bun's performance advantages
Note: If you're using Node.js, cross-env is the excellent standard choice. bunjs-env is designed specifically for Bun users who want native integration.
Examples
Development
bunjs-env NODE_ENV=development DEBUG=true bun run dev
bunjs-env NODE_ENV=test DATABASE_URL=test.db bun testProduction
bunjs-env NODE_ENV=production bun run build
bunjs-env NODE_ENV=production PORT=8080 bun run startCI/CD
bunjs-env NODE_ENV=test CI=true bun run test:coverageCLI Options
-h, --help— Show help message--debug— Enable debug output showing environment variables and command execution
Requirements
- Bun.js >= 1.0.0
API
Environment variables must follow standard naming conventions:
- Start with a letter or underscore
- Contain only letters, numbers, and underscores
- Format:
KEY=value
Migration from cross-env
Switching from cross-env is straightforward - just replace cross-env with bunjs-env:
# Before (cross-env)
cross-env NODE_ENV=production npm run build
# After (bunjs-env)
bunjs-env NODE_ENV=production bun run buildLicense
MIT License — see LICENSE for details.
