I recently upgraded Node.js on my Windows machine to version v22.12, and now any script I run from a file exits immediately without displaying any output. For example:
> node test.js
# (no output, program finishes instantly)
Here is a minimal example of test.js
(though the content seems irrelevant; even a single console.log()
fails to produce output):
console.log("Hello from Node.js");
setInterval(() => {
console.log("Still running...");
}, 2000);
Key observations:
- If I run the same code inline using
-e
, it does work:node -e "console.log('Hello from inline'); setInterval(() => {console.log('Still running inline...');}, 3000)"
- If I downgrade Node.js to v20.18, the file-based execution works as expected, producing output as normal.
- Before upgrading to 22.12, everything worked correctly on the same machine.
- After reverting to 20.18, it started working again without changing any other settings.
Question:
- Was there a change in Node.js v22.12 that affects how scripts should be started on Windows?
- Or could there be a specific configuration or security policy on my Windows PC that might cause this behavior?
- Has anyone else encountered this issue or found a workaround?
For now, I’m okay staying on v20.18 since it resolves the problem, but I’d prefer to upgrade if there’s a known fix or setting adjustment. Any insights would be much appreciated!