You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes env files are used as config files, therefore it should be allowed to set an --env-file in NODE_OPTIONS, for example in the .npmrc file, so that it applies to all scripts of that specific project.
What is the feature you are proposing to solve the problem?
Allowing for the --env-file flag to be supported in NODE_OPTIONS.
I see, but I see no other solution for project specific .env, right? Do we have a way of knowing where the NODE_OPTIONS are coming from? If so, just disabling it for the .env recursive case might be a way? 🤔
Well, that can raise many issues and confusion since you can define NODE_OPTIONS inside the env file
Not really. Command line switches take priority over all other methods of defining the same values. Just ignore any NODE_OPTIONS in the env file when it is being loaded by --env-file. The current state of rejecting the option is frustrating and surprising.
Reacted by Rodrigo Bastos, Christopher Monsanto, Sergey Kozlov, Bit0r, Graham Ballantyne and avernikoz
Can you please highlight what makes it "technically impossible"?
With the current state it is not possible, I didn't say impossible :-)
To summarize, if you refactor how we load and initialize node options as well as env file, it is possible. although, i think it will make both implementations more complex with little gain. if you think you can land it, with less unmaintainability, PRs are welcome.
@anonrig you seem to have direct knowledge of why it is impossible. I am asking you to provide a summary of that knowledge. As a reader of this thread, there is nothing in it that tells me why it would be closed without being solved.
@anonrig you seem to have direct knowledge of why it is impossible. I am asking you to provide a summary of that knowledge. As a reader of this thread, there is nothing in it that tells me why it would be closed without being solved.
You're right. I'll write an in depth analysis of my thoughts when I have the time. Meanwhile, I'm reopening the issue.
Reacted by James Sumners, Erfan Safari, Rogério Vicente, Graham Ballantyne, Gus and Jonathan Raoult
This seems to be the closest I have found to my task. Perhaps someone here can give me a hint?
I want to use --env-file (--env-file-if-exists tbh) together with running npm package. Moreover, I want to get this cross-platform and without using third-party packages.
I think I got closer to it with npx and here I am:
npx --node-options='--env-file-if-exists=.env' playwright test
node: --env-file-if-exists= is not allowed in NODE_OPTIONS
Perhaps there is another way?
Reacted by Cameron Cadiz, Gus, Lucas Recknagel, Damien Maillard, Aleksi Pekkala, Pierre Penelon, Wojciech Maj and Jakub Zomerfeld
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the
never-staleIssues and PRs exempt from automated stale handling.
label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
Reacted by Damien Maillard, James Sumners, Vladyslav Zubko, Brendon Matos, whoisYeshua, Kendell, Pierre Penelon, Graham Ballantyne and Hiroki Osame
@anonrig you seem to have direct knowledge of why it is impossible. I am asking you to provide a summary of that knowledge. As a reader of this thread, there is nothing in it that tells me why it would be closed without being solved.
You're right. I'll write an in depth analysis of my thoughts when I have the time. Meanwhile, I'm reopening the issue.
any updates?
Reacted by Graham Ballantyne, Jakub Zomerfeld and Cristian Torres
Activity
MoLow commentedon Dec 13, 2023
Well, that can raise many issues and confusion since you can define NODE_OPTIONS inside the env file
afonsojramos commentedon Dec 13, 2023
I see, but I see no other solution for project specific
.env, right? Do we have a way of knowing where the NODE_OPTIONS are coming from? If so, just disabling it for the.envrecursive case might be a way? 🤔jsumners commentedon Mar 28, 2024
Not really. Command line switches take priority over all other methods of defining the same values. Just ignore any
NODE_OPTIONSin the env file when it is being loaded by--env-file. The current state of rejecting the option is frustrating and surprising.kireerik commentedon Apr 22, 2024
I think this was working before version 20.12.x (related issue: remy/nodemon#2194).
remy commentedon Apr 22, 2024
Not a related issue. They've opened an issue that is not related to nodemon at all (just to prevent confusion for anyone else)
anonrig commentedon May 28, 2024
Closing since technically this is not possible with the current implementation.
jsumners commentedon Jun 8, 2024
Can you please highlight what makes it "technically impossible"?
anonrig commentedon Jun 8, 2024
With the current state it is not possible, I didn't say impossible :-)
To summarize, if you refactor how we load and initialize node options as well as env file, it is possible. although, i think it will make both implementations more complex with little gain. if you think you can land it, with less unmaintainability, PRs are welcome.
jsumners commentedon Jun 10, 2024
@anonrig you seem to have direct knowledge of why it is impossible. I am asking you to provide a summary of that knowledge. As a reader of this thread, there is nothing in it that tells me why it would be closed without being solved.
anonrig commentedon Jun 10, 2024
You're right. I'll write an in depth analysis of my thoughts when I have the time. Meanwhile, I'm reopening the issue.
dartess commentedon Nov 28, 2024
This seems to be the closest I have found to my task. Perhaps someone here can give me a hint?
I want to use
--env-file(--env-file-if-existstbh) together with running npm package. Moreover, I want to get this cross-platform and without using third-party packages.I think I got closer to it with
npxand here I am:Perhaps there is another way?
github-actions commentedon May 28, 2025
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the never-staleIssues and PRs exempt from automated stale handling.
label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
songkeys commentedon Oct 25, 2025
any updates?