nodejs / nodejs/node

Support variable expansion in DotEnv features

Open
#65,705 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

dotenv feature request
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name files or tests; start by locating Node's DotEnv implementation and its existing test coverage. Trace how values are parsed and resolved, then define tests for ${APPLICATION_PORT} expansion and expected behavior for overrides and ordering. Done means the proposed expansion behavior is implemented and covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.