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
{{ message }}
Repository navigation
Node 22 doesn't honor the --watch-preserve-output command-line parameter #56330
I have this command that I run with npm: node --env-file=.env --watch-preserve-output --watch-path ./dist/server and it has always worked as expected. Now, after switching (using nvm) to node 22, the screen is always cleared upon restarting. If I switch back to node 20 (with nvm), the --watch-preserve-output parameter is honored.
How often does it reproduce? Is there a required condition?
It happens all the times
What is the expected behavior? Why is that the expected behavior?
This is apparently a regression on the node 20 line.
You can run this command in following way, it runs identically in both node 20 and 22. node --env-file=.env --watch --watch-preserve-output ./dist/server
@claudioc As per the example in https://nodejs.org/api/cli.html#--watch-preserve-output, --watch-preserve-output is used with --watch. If you add --watch before --watch-preserve-output, it may preserve previous logs. I have added it below. "dev:start": "wait-on ./dist/server/app.js && node --env-file=.env --watch --watch-preserve-output --watch-path ./dist/server ./dist/server/app.js"
@abdullahshahid95 OK, adding the --watch flag works again. You are pointing to the documentation, but the documentation is confusing at least:
--watch-path "Starts Node.js in watch mode and specifies what paths to watch."
So why the --watch is ALSO needed to have the -watch-preserve-output work as expected!? Something is a bit unclear: according to the doc you should not need to add --watch to have -watch-preserve-output
@claudioc Yes, it's definitely confusing :-)
I tried few combinations and found out, --watch watches main file and imported files. --watch-path only watches files in specific paths. --watch-preserve-output works only with --watch and preserves previous output.
Screenshot of documentation below.
This issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
This issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 240 days).
If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.
Activity
abdullahshahid95 commentedon Dec 23, 2024
You can run this command in following way, it runs identically in both node 20 and 22.
node --env-file=.env --watch --watch-preserve-output ./dist/serverclaudioc commentedon Dec 23, 2024
@abdullahshahid95 my full script line is the following. Your line doesn't contain the script to run
"dev:start": "wait-on ./dist/server/app.js && node --env-file=.env --watch-preserve-output --watch-path ./dist/server ./dist/server/app.js",abdullahshahid95 commentedon Dec 24, 2024
@claudioc As per the example in https://nodejs.org/api/cli.html#--watch-preserve-output, --watch-preserve-output is used with --watch. If you add --watch before --watch-preserve-output, it may preserve previous logs. I have added it below.
"dev:start": "wait-on ./dist/server/app.js && node --env-file=.env --watch --watch-preserve-output --watch-path ./dist/server ./dist/server/app.js"claudioc commentedon Dec 24, 2024
@abdullahshahid95 OK, adding the --watch flag works again. You are pointing to the documentation, but the documentation is confusing at least:
--watch-path "Starts Node.js in watch mode and specifies what paths to watch."
So why the --watch is ALSO needed to have the -watch-preserve-output work as expected!? Something is a bit unclear: according to the doc you should not need to add --watch to have -watch-preserve-output
abdullahshahid95 commentedon Dec 24, 2024
@claudioc Yes, it's definitely confusing :-)

I tried few combinations and found out,
--watchwatches main file and imported files.--watch-pathonly watches files in specific paths.--watch-preserve-outputworks only with--watchand preserves previous output.Screenshot of documentation below.
github-actions commentedon Apr 26, 2026
This issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
github-actions commentedon May 26, 2026
This issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 240 days).
If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.