Node.js console gets closed immediately after i execute the program from Visual Studio 2012 in Windows 8 Node.js console gets closed immediately after i execute the program from Visual Studio 2012 in Windows 8 node.js node.js

Node.js console gets closed immediately after i execute the program from Visual Studio 2012 in Windows 8


From the Debug menu in Visual Studio choose "Options". After this choose "NodeJS Tools" and tick the checkbox "Wait for input when process exits normally".


Instead of directly executing node app.js from Visual Studio, you could instead call a batch file:

wait.bat app.js

Which inside of wait.bat it simply:

node %1pause press [enter]

or, you could do this on one line, or wrap it in a module or a function:

require('readline')    .createInterface(process.stdin, process.stdout)    .question("Press [Enter] to exit...", function(){        process.exit();});

It's using an currently marked as "unstable" module of Node to read line input from stdin. It ignores the input though and then closes the process using the exit function.


  1. Open the Visual Studio Options property pages from the menu bar with Tools -> Options.
  2. In the menu tree on the left-hand side, select Node.js Tools -> General
  3. Tick the box labelled "Wait for input when process exits normally"

enter image description here