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.
npm install dotenv-flow-cliVerified import paths — ran on the pinned version, not inferred.
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.
Always use the `--` separator before the actual command if it takes additional arguments (e.g., `dotenv-flow -- my-command -p something`).
Refer to the comprehensive `dotenv-flow` documentation to understand the exact file loading precedence and override rules.
Be aware that variables like `APP_URL=http://${IP}:${PORT}` will automatically resolve. If this behavior is undesired, ensure variables are properly escaped or consider alternative tools.While functional, major updates or compatibility with newer Node.js versions or dependency changes might be slow. Consider pinning specific versions of underlying dependencies like `dotenv-flow` if stability is critical.
Install globally using `npm install -g dotenv-flow-cli` or `yarn global add dotenv-flow-cli`. Alternatively, use `npx dotenv-flow <command>` for ad-hoc execution without global installation.
Verify `.env` filenames adhere to `dotenv-flow` conventions (e.g., `.env`, `.env.development`, `.env.production`, `.env.local`). Ensure `NODE_ENV` is correctly set before running the `dotenv-flow` command, or use the `-p` option to specify the correct directory.