dotenv-flow CLI

1.1.1 · maintenance · verified Wed Apr 22

dotenv-flow-cli is a command-line interface (CLI) tool designed to execute shell commands with environment variables loaded from `.env` files using `dotenv-flow`'s sophisticated loading logic. It automatically processes different `.env` files based on the `NODE_ENV` and other `dotenv-flow` conventions, allowing for environment-specific configurations (e.g., `.env.development`, `.env.production`, `.env.local`). The current stable version is 1.1.1, with the last publish date over two years ago, suggesting a maintenance or stable cadence driven by its upstream dependencies, `dotenv-flow` and `dotenv-expand`. Its key differentiator from `dotenv-cli` is the reliance on `dotenv-flow`'s specific cascading `.env` file loading strategy, which includes support for `development`, `test`, `production`, and `.local` overrides, along with automatic variable expansion. It is intended as a direct wrapper, providing a convenient executable for managing environment variables for CLI commands.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates global installation, creation of layered `.env` files, and executing Node.js commands to show how `dotenv-flow-cli` loads environment variables based on `NODE_ENV` and `.local` overrides.

npm install -g dotenv-flow-cli

# Create example .env files
echo "APP_NAME=MyFlowApp" > .env
echo "API_KEY=dev_123" > .env.development
echo "API_KEY=prod_xyz" > .env.production
echo "DEBUG_MODE=true" > .env.development.local

# Run a command in development environment
NODE_ENV=development dotenv-flow -- node -e "console.log('App Name:', process.env.APP_NAME); console.log('API Key:', process.env.API_KEY); console.log('Debug Mode:', process.env.DEBUG_MODE);"

# Run a command in production environment
NODE_ENV=production dotenv-flow -- node -e "console.log('App Name:', process.env.APP_NAME); console.log('API Key:', process.env.API_KEY); console.log('Debug Mode:', process.env.DEBUG_MODE);"

view raw JSON →