Title: dotenv: override does not behave correctly with watch enabled · Issue #61412 · nodejs/node · GitHub
Open Graph Title: dotenv: override does not behave correctly with watch enabled · Issue #61412 · nodejs/node
X Title: dotenv: override does not behave correctly with watch enabled · Issue #61412 · nodejs/node
Description: Version >= 24.12.0 Platform Darwin MBP-M1-RJQ0.local 24.6.0 Darwin Kernel Version 24.6.0: Wed Nov 5 21:33:58 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6000 arm64 Subsystem No response What steps will reproduce the bug? See h...
Open Graph Description: Version >= 24.12.0 Platform Darwin MBP-M1-RJQ0.local 24.6.0 Darwin Kernel Version 24.6.0: Wed Nov 5 21:33:58 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6000 arm64 Subsystem No response ...
X Description: Version >= 24.12.0 Platform Darwin MBP-M1-RJQ0.local 24.6.0 Darwin Kernel Version 24.6.0: Wed Nov 5 21:33:58 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6000 arm64 Subsystem No respon...
Opengraph URL: https://github.com/nodejs/node/issues/61412
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"dotenv: override does not behave correctly with watch enabled","articleBody":"### Version\n\n\\\u003e= 24.12.0\n\n### Platform\n\n```text\nDarwin MBP-M1-RJQ0.local 24.6.0 Darwin Kernel Version 24.6.0: Wed Nov 5 21:33:58 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6000 arm64\n```\n\n### Subsystem\n\n_No response_\n\n### What steps will reproduce the bug?\n\nSee https://github.com/arkon/nodejs-env-file-override-repro\n\nWhen using `--watch`, subsequent env files do not override the prior ones as expected by the [docs](https://nodejs.org/en/learn/command-line/how-to-read-environment-variables-from-nodejs) if using both `--env-file` and `--env-file-if-exists`:\n\n\u003e Also, you can pass multiple `--env-file` arguments. Subsequent files override pre-existing variables defined in previous files.\n\n```\n=== Test 1: --env-file + --env-file-if-exists ===\nWithout --watch:\nv24.11.1 MY_VAR: from_dotenv_local\nv24.12.0 MY_VAR: from_dotenv_local\nv24.13.0 MY_VAR: from_dotenv_local\nv25.3.0 MY_VAR: from_dotenv_local\n\nWith --watch:\nv24.11.1 MY_VAR: from_dotenv_local\nv24.12.0 MY_VAR: from_dotenv \u003c-- BUG: should be from_dotenv_local\nv24.13.0 MY_VAR: from_dotenv \u003c-- BUG\nv25.3.0 MY_VAR: from_dotenv \u003c-- BUG\n\n=== Test 2: --env-file + --env-file (works correctly) ===\nWithout --watch:\nv24.11.1 MY_VAR: from_dotenv_local\nv24.12.0 MY_VAR: from_dotenv_local\nv24.13.0 MY_VAR: from_dotenv_local\nv25.3.0 MY_VAR: from_dotenv_local\n\nWith --watch:\nv24.11.1 MY_VAR: from_dotenv_local\nv24.12.0 MY_VAR: from_dotenv_local\nv24.13.0 MY_VAR: from_dotenv_local\nv25.3.0 MY_VAR: from_dotenv_local\n\n=== Test 3: --env-file-if-exists + --env-file-if-exists (works correctly) ===\nWithout --watch:\nv24.11.1 MY_VAR: from_dotenv_local\nv24.12.0 MY_VAR: from_dotenv_local\nv24.13.0 MY_VAR: from_dotenv_local\nv25.3.0 MY_VAR: from_dotenv_local\n\nWith --watch:\nv24.11.1 MY_VAR: from_dotenv_local\nv24.12.0 MY_VAR: from_dotenv_local\nv24.13.0 MY_VAR: from_dotenv_local\nv25.3.0 MY_VAR: from_dotenv_local\n```\n\n### How often does it reproduce? Is there a required condition?\n\nThis is always reproducible when using `--watch` and mixing `--env-file` and `--env-file-if-exists`.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nDocumented override behaviour, aligning with behaviour seen when not using `--watch`.\n\n### What do you see instead?\n\nSubsequent env files do not override earlier ones.\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/arkon","@type":"Person","name":"arkon"},"datePublished":"2026-01-17T16:43:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/61412/node/issues/61412"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:462ec936-1f7e-7b8e-4ba1-d294bf443c12 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8F62:31D4:23D9384:33CF0AD:6A4D18F9 |
| html-safe-nonce | eee23902a6712553ea76846c81ba9b1a4fa2382cc4e6351bcc2273cf76c52be9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RjYyOjMxRDQ6MjNEOTM4NDozM0NGMEFEOjZBNEQxOEY5IiwidmlzaXRvcl9pZCI6IjExMTAwNzE2Mzg3NTEzNzc4NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7ca3ac63dea12cd1f009afa9a31395f617f2a755306317c8bdc859cb91c39ab2 |
| hovercard-subject-tag | issue:3825515065 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/61412/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0d50c64a0622c8989328a8659300a2b871b8b5ae079a1906ffae68bc6fc3deb5/nodejs/node/issues/61412 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0d50c64a0622c8989328a8659300a2b871b8b5ae079a1906ffae68bc6fc3deb5/nodejs/node/issues/61412 |
| og:image:alt | Version >= 24.12.0 Platform Darwin MBP-M1-RJQ0.local 24.6.0 Darwin Kernel Version 24.6.0: Wed Nov 5 21:33:58 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6000 arm64 Subsystem No response ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | arkon |
| hostname | github.com |
| expected-hostname | github.com |
| None | bcb4661e6fb4fe8b394c51ea02ccdb2236d40dc59afc75a3bbba50bf6517134c |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | fb70bd3c4b2bec429781b65419e912c66e2d5581 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width