Skip to content

--env-file is silently ignored when using --run #62988

Description

@PolariTOON

Version

v24.15.0

Platform

Linux beta 6.8.0-106-generic #106-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar  6 07:58:08 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Given the following files:

  • package.json:

    {
      "type": "module",
      "scripts": {
        "start": "echo $NODE_ENV"
      }
    }
  • .env.production:

    NODE_ENV=production

Run the following command:

node --env-file=.env.production --run start

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

Always

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

It outputs PRODUCTION.

What do you see instead?

Nothing

Additional information

I was expecting to be able to provide a whole set of environment variables to commands from a file, instead of setting them either in the shell or the surrounding environment (something like NODE_ENV=production node --run start) or rewriting the command. I didn't find information in the docs saying --env-file and --run can not be combined. Same for --env-file-if-exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions