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?
Debugging With PM2 And Vscode
Asked Answered
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
I have .yaml file loaded by too many microservices. Then? Like apps: - name: account script: app.js out_file: /dev/null error_file: /dev/null cwd: ../sk_account env: UV_THREADPOOL_SIZE: 12 PUTTU_IP: 127.0.0.1 REDIS_CON: localhost:6379 ES_URL: localhost:9200 MONGO_URL: mongodb:// XAMPP_URL: HOST_NAME: localhost CONFIG_URL: ../config/globals.js - name: apigateway so on... –
Dav
can anyone reply on this! –
Dav
I'm not sure what you meant here, please check out this link for further details on how to attach process to vs code debugger. code.visualstudio.com/docs/nodejs/… –
Cervantez
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.
But This is not the solution for the above question. –
Dav
© 2022 - 2024 — McMap. All rights reserved.