Closed Git-Harshit closed 2 years ago
npm start just runs your own script. Does that support control-c?
Also, npm has no LTS and v7 is EOL. Try v8.
I have also came across with that issue sometimes, but I didn't bother because I thought it was a typo 👀
npm start just runs your own script. Does that support control-c?
No, that Control+C isn't handled within the running script, but I guess npm does handle it since it captures the Control+C keyboard combination and prompts for "Terminate batch job (Y/N)?" following it, which gets exit on any input either beginning with a 'y' (which is desired) or 'n' (which isn't desired) or even a repeated Control+C key combination.
"Terminate batch job" is a prompt that the windows command prompt gives. SIGINT is not something that npm handles when running scripts.
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
I am using the latest npm LTS (Long Term Support) version v7.20.3 at the time of reporting this issue.
Normally, when we press Ctrl + C keyboard shortcut to terminate our running program, it prompts us with "Terminate batch job (Y/N)?", before actually stopping it. However, even when the response entered is a no (tried with entering 'n', 'no', 'N', 'No', 'NO' to this prompt), it still exits the running script. This is an undesired response for the case of denial to this prompt, as a non-termination should mean that the user has changed their mind on being prompted, and would like to keep the script running.
This behavior has been observed on Windows 10 Powershell. A snapshot of this has been attached:
Expected Behavior
On pressing Ctrl + C keyboard shortcut, when "Terminate Batch Job (Y/N)?" prompt appears, it should ideally terminate the script only upon a positive confirmation (with case-insensitive responses like: 'y', 'yes'), and on a negation with responses like 'n'/'no', the termination of program must not be done, since it has prompted for the termination and the choice must still remain over to user.
i.e.,
Terminate batch job (Y/N)?
should not terminate the script and continue running it in case of 'no' as a response.Steps To Reproduce
npm start
)Environment
prefix = "C:\Users\Devil's Lair\AppData\Roaming\npm"
; node bin location = C:\Program Files\nodejs\node.exe ; cwd = C:\Users\Devil's Lair\Desktop\Temp\Swiggy IPP Backend Round 2 Case Study\food-app ; HOME = C:\Users\Devil's Lair ; Run
npm config ls -l
to show all defaults.