镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Multiple --env-file no longer work with --watch #60599

Description

@tclzcja

Version

v25.1.0

Platform

Microsoft Windows NT 10.0.26200.0 x64

Subsystem

No response

What steps will reproduce the bug?

  1. Create .a.env, and .b.env.
  2. .a.env includes: "ENV_VAR_A=123".
  3. .b.env includes: "ENV_VAR_B=456".
  4. create index.js that does this:
console.log(process.env.ENV_VAR_A)
  1. Run "node --env-file=.a.env --env-file=.b.env --watch index.js".
  2. Result output "undefined" (instead of 123)

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

Expected to see "123", because both .env files should be included and loaded as the command says. Notice that the env vars in those 2 files are different, so those 2 files should be "merged" as result, instead of be completely overwritten by the last one.

What do you see instead?

It always output "undefined" when "--watch" is added. It does output "123" when "--watch" is removed.

Additional information

Until Node.js v24.4, the multiple --env-file works well with --watch. I updated to v25.1.0 yesterday, and this pattern no longer works. As I've mentioned above, highly likely this is caused by "--watch" flag.

Activity

  1. StefanStojanovic commented on Nov 6, 2025

    @StefanStojanovic
    Contributor

    I've looked into this briefly. This was introduced in version 25.1. In v25.0 it works as expected. Also, it is only observable in watch mode; running node --env-file=a.env --env-file=b.env index.js prints the correct output.

  2. targos commented on Nov 6, 2025

    @targos
    Member

    Likely caused by #60178

  3. marco-ippolito commented on Nov 6, 2025

    @marco-ippolito
    Member

    confirm it has been caused by #60178 I'm working on a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions