I've been having trouble connecting the Visual Studio '17 15.6.4 debugger to a browser and server code when using node as the server, and a web page with react. When I run node directly or Ctrl-F5, the site runs fine and I can see it in a browser. Running F5 to debug the server code there is a message of several lines that flashes in the node prompt when I run F5 debug and then it closes. I've tried switching the default browser. I've tried adding breakpoints to the server code, require('readline');
to read a line, and setTimeout() on line 1 which didn't work so the problem is before user code. How can I get the cmd prompt to stay open so I can read the error? Whatever the problem is might also fix whatever is keeping me from attaching manually to the browser to debug the front end.

- 1,418
- 2
- 14
- 25
1 Answers
I finally figured out what was broken using a small modification of this answer 1. Create a bat file named pause.bat with the following which spawns node with the input arguments from VS and then pauses keeping cmd open:
"C:\Program Files\nodejs\node.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9
pause
Open project properties and set Node.exe path
to the location of pause.bat
The error was:
C:\Users\user135711\Downloads\Ghost-1.22.0>"C:\Program Files\nodejs\node.exe" --debug-brk 5858 --nolazy C:\Users\user135711\Downloads\Ghost-1.22.0\index.js (node:7112) [DEP0062] DeprecationWarning:
node --debug
andnode --debug-brk
are invalid. Please usenode --inspect
ornode --inspect-brk
instead.
Changing pause.bat to
"C:\Program Files\nodejs\node.exe" --inspect-brk %2 %3 %4 %5 %6 %7 %8 %9
pause
starts the server but in VS the break points don't get hit still. I have the most recent VSNT extension... hmm
2nd solution: I haven't verified this, but all output supposedly should be visible in the Visual Studio output window.

- 1,418
- 2
- 14
- 25