Warm tip: This article is reproduced from stackoverflow.com, please click
node.js windows command-prompt httpserver

Why do I sometimes need to hit ENTER in command prompt for Node.js to continue running a script?

发布于 2020-03-31 23:01:00

I have a node.js server which I start with a nodejsserver.bat file on Windows. It logs a few things in the console. The weird thing is that sometimes I need to hit ENTER in the command prompt for node.js to continue, otherwise it won't accept any connections. After hitting ENTER it prints a few lines in the console and then it runs fine, like it was waiting for some user input.

Does anyone have a clue why it's waiting for ENTER? The code does not contain anything like prompt, query or readline.

Questioner
Casper
Viewed
86
Casper 2020-02-01 17:57

When you activate text selection in the command prompt, this does not only pause the output to console, this also pauses the actually node.js script which was running. Therefor it can block connections to your node.js server.

Thanks to @Joe and @Eryk Sun.

"In select mode the console window title is also modified to begin with "Select". A casual click on the window can enter select mode if "QuickEdit Mode" is enabled in the console properties or defaults. If quick-edit mode is disabled, you have to first enter mark mode via the control menu or Ctrl+M"