Skip to content

Support variable expansion in DotEnv features #65705

Description

@WoodyWoodsta

What is the problem this feature will solve?

Sometimes it's helpful to derive the value of variables from other variables, using variable expansion.

For example, consider the following .env file:

APPLICATION_PORT: 8080
BASE_URL: http://localhost:8080

The APPLICATION_PORT and BASE_URL should have the same port. For reasons external to this issue, BASE_URL cannot be split into two variables without causing confusion.

If there are external overrides to APPLICATION_PORT, they won't remain in sync with BASE_URL.

What is the feature you are proposing to solve the problem?

Instead we could write .env files like this:

APPLICATION_PORT: 8080
BASE_URL: http://localhost:${APPLICATION_PORT}

This is already supported by at least bash, and the concept of variable expansion in environmental configuration is also common in ecosystems such as Kubernetes.

What alternatives have you considered?

  • Using dotenvx
  • Splitting variables up into their lowest common set

Metadata

Metadata

Assignees

No one assigned

    Labels

    dotenvIssues and PRs related to .env file parsing.feature requestIssues requesting new Node.js features.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions