dotenv-cli

A command-line tool that loads .env files and runs any command with those environment variables set.

Tool
npm
v11.0.0
602 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
40 /100 Fair
Development Activity 8
Maintenance 20
Community 52
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
38 /100 Needs Attention
Architecture 55
Code Quality 38
Innovation 30
Learning Curve 30

dotenv-cli is a small command-line utility that loads environment variables from one or more .env files and then executes a given command with those variables applied to its environment. It solves a practical cross-platform problem: the VARIABLE=value command syntax used on Unix shells doesn’t work on Windows, so dotenv-cli sidesteps that entirely by loading variables into a spawned child process itself.

Beyond basic .env loading, it supports multiple -e file paths (first file wins on conflicting keys), cascading environment-specific files via -c (.env, .env.local, .env.<environment>, .env.<environment>.local), inline variable overrides via -v, variable expansion (via dotenv-expand) with an opt-out flag, and an override mode that lets .env values take priority over already-set system variables.

What You Get

  • Cross-platform env loading that works the same in Bash, PowerShell, and CMD, unlike the VAR=value command shell syntax.
  • Multiple .env file support via repeated -e flags, with first-file-wins precedence on conflicting keys.
  • Cascading environment files (-c) that mimic the .env / .env.local / .env.<environment> / .env.<environment>.local pattern used by frameworks like Create React App.
  • Inline variable injection via -v name=value, which takes precedence over file-based values.
  • Variable expansion (via dotenv-expand) so values like APP_URL=http://${IP}:${PORT} resolve automatically, with a —no-expand escape hatch.

Common Use Cases

  • Running an npm script with test-specific environment variables loaded from .env.test.
  • Injecting secrets into a build or deploy command without needing native shell env-var syntax.
  • Printing a single resolved environment variable value for use in shell scripting via -p.
  • Loading a custom-named env file (e.g. .env.staging) into a Maven or other non-Node build command.

Under The Hood

Architecture

dotenv-cli is implemented as a single ~130-line script (cli.js) with no internal module boundaries: argument parsing (via minimist), path/cascade resolution, dotenv loading, variable expansion, and child-process spawning all happen sequentially in one file. Execution flows linearly from parsing process.argv, through building a list of candidate .env paths (adjusted for the -c cascade flag), to calling dotenv.config() per path, running dotenv-expand, merging in -v overrides, and finally spawning the target command via cross-spawn with stdio: 'inherit' and explicit forwarding of process signals (SIGINT, SIGTERM, etc.) to the child. There is no abstraction layer to change if the core behavior shifts — the whole tool is one procedural script, appropriate for its scope but with no separation of concerns.

Tech Stack

The tool targets Node.js and ships as a single npm bin entry (dotenv). Its runtime dependencies are minimal and current: dotenv (^17.1.0) for .env parsing, dotenv-expand (^12.0.0) for ${VAR} interpolation, cross-spawn (^7.0.6) for cross-platform child-process spawning, and minimist (^1.2.6) for flag parsing. The only dev dependency is the standard linter (v16) for style enforcement; there is no bundler, transpiler, or TypeScript — the source is plain CommonJS require()-based JavaScript distributed as-is via npm and Yarn.

Code Quality

No test files or test framework exist anywhere in the repository, and there is no CI configuration checked into the repo. Code style is enforced only via the standard linter (npm run lint), which mandates a consistent formatting convention but does not substitute for behavioral tests. Error handling is present but minimal: invalid -v arguments and conflicting -c/-o flags print a message and call process.exit(1), and child-process exit codes/signals are explicitly propagated. There is no static typing (plain JavaScript, no JSDoc types or TypeScript), so correctness relies entirely on manual testing and the small surface area of the script.

API Design The CLI surface is compact and mirrors common dotenv conventions users already know from other tools (-e, -c, -v, -p, --no-expand, -o/--override), keeping the learning curve low for anyone familiar with .env-file conventions. The -- separator convention for passing flags through to the wrapped command is a deliberate, well-documented affordance that avoids the tool’s own argument parser swallowing flags meant for the child process. Getting started requires zero configuration beyond installing the package and optionally creating a .env file — there is no setup boilerplate.

Used by 33 apps in this directory

TypeScript
90%
MIT

Plasmic

CMS · Design Tools · Low Code Platforms

7,125

The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.

View details
81
Repo Health
78
Technical
64
Dependency
Built with
TypeScript 90%
Updated 6 days ago
TypeScript
81%
AGPL 3.0

Postiz

Automation · Social Media

37,683

The agentic social media scheduler — AI-powered content creation, 33-platform posting, and team workflows, all self-hosted.

View details
92
Repo Health
70
Technical
63
Dependency
Built with
TypeScript 81%
JavaScript 11%
Updated 6 days ago
TypeScript
95%
AGPL 3.0

Rallly

Scheduling

5,318

Self-hostable group scheduling polls that eliminate back-and-forth emails and find the best meeting time for everyone.

View details
91
Repo Health
75
Technical
66
Dependency
Built with
TypeScript 95%
Updated 6 days ago
JavaScript
89%
GPL 3.0

Screenity

Productivity · Video Editors

18,806

Free, privacy-first Chrome screen recorder with real-time annotation, AI camera blur, and a built-in video editor — no sign-in or limits required.

View details
74
Repo Health
62
Technical
70
Dependency
Built with
JavaScript 89%
Updated 1 weeks ago
Python
100%
Other

Sourcebot

AI Code Assistants · Developer Tools · Search

4,005

A self-hosted, AI-powered code search engine that indexes every repo across GitHub, GitLab, Bitbucket, Gitea, Gerrit, and Azure DevOps, so both engineers and coding agents can search, browse, and ask questions about your codebase from one place.

View details
86
Repo Health
83
Technical
61
Dependency
Built with
Python 100%
Updated 1 weeks ago
TypeScript
89%
Other

Hexclave

Authentication · Developer Tools

6,877

The open-source user infrastructure platform — authentication, teams, payments, emails, analytics, and more on a single unified user model.

View details
88
Repo Health
80
Technical
66
Dependency
Built with
TypeScript 89%
Updated 5 days ago
TypeScript
96%
Other

superglue

AI Agents · Data Engineering · Developer Tools

2,066

superglue is an AI-agent-driven integration engine that turns plain-English descriptions of enterprise systems into production-grade API tools, ERP/CRM connectors, and data pipelines — self-hosted or cloud, Y Combinator-backed (W25).

View details
42
Repo Health
79
Technical
67
Dependency
Built with
TypeScript 96%
Updated 2 months ago
TypeScript
85%
Apache 2.0

superset

AI Code Assistants · AI Development

15,503

Orchestrate an army of AI coding agents—Claude Code, Codex, Gemini CLI, and more—running simultaneously in isolated git worktrees from a single Electron desktop app.

View details
86
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 85%
Updated 5 days ago
TypeScript
84%
Other

twenty

CRM

59,615

The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.

View details
92
Repo Health
82
Technical
64
Dependency
Built with
TypeScript 84%
MDX 14%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers