Skip to content
uencoder

Dotenv Expand

dotenv-expand expands variable references in .env files so that $VAR or ${VAR} refer to the value of an already-defined variable.

Purpose

To support references between variables in .env files, avoiding duplicate definitions and keeping configuration consistent.

Mechanism

While parsing .env, $VAR and ${VAR} in values are replaced with the value of VAR already defined in the same file or in process.env. A default value is supported as ${VAR:-default}.

Use cases

  • Environment variable reference expansion
  • Composing Docker .env files
  • CI/CD variable reuse

Related tools

References