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:
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.
Version
v24.15.0
Platform
Subsystem
No response
What steps will reproduce the bug?
Given the following files:
package.json:{ "type": "module", "scripts": { "start": "echo $NODE_ENV" } }.env.production:Run the following command:
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-fileand--runcan not be combined. Same for--env-file-if-exists.