Visual studio Code - Debugging node application

preview_player
Показать описание

The project setup, is a basic express application, generated with express-generator.

The project, vscode-debugging-node is available at GitHub

While executing the $ grunt start task, if a env variable named NODE_INSPECTOR=* is passed, the server is started in --debug mode. When the grunt task is executed in --debug mode, along with node-inspector running in parallel, I can use Chrome to debug the complete application.

Is this possible to debug such situation in visual studio code? If yes, it will be of great help to know the details.
Рекомендации по теме
Комментарии
Автор

Yes, this is possible. Click the "Debug" icon on the left. Click the drop down that says "Launch Server" and change that to "Attach". Click the green "Start" arrow. If you're node app is running from gulp and is listening to  5858 or 7000 or whatever, then the attach will use the last part of the config to connect to 5858. You can set breakpoints in your code and request the page, you should see the debugger break at that breakpoint.

Just make sure that
1) NODE_INSPECTOR=* env variable is set and the server is running
2) Read the output and confirm "debugger listening on port 7000" or whatever
3) That your launch.json port is set to 7000 or whatever

ozten