Visual Studio code has some awesome debug functionality built in that makes it easy to debug applications with node. However, my application is configured to use PM2 version 3.4.1. node version 6.17.1 How can I set up Visual Studio Code to debug with PM2?
2 Answers
3
votes
Vs code has a debugging option called “Attach” which allows you to attach to a running Node.js program, A sample configuration would be
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229
}
Now you need to start your Node.js program like below
$ pm2 start "My App" --node-args="--inspect-brk" --watch
vs code docs : https://code.visualstudio.com/docs/editor/debugging#_launch-versus-attach-configurations
-2
votes
Its possible to debug one of the micro-service from the list by stopping it like "sudo pm2 stop sk_account"
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/sk_account/app.js"
}
]
Here "sk_account" is my micro-service name Form the list.