Debug NodeJS in VSCode
On remote server where application is running
- Set up inspection in Node container:
kubectl edit deployment api-gateway
Containers:
api-gateway:
Command:
...
node --inspect=0.0.0.0 app.js;
- Clone the repository:
git clone https://gitlab.app.com/appTeam/Product/FE/vnext
- Checkout release:
cd vnext
git checkout release/l8.2.4
- Open folder in vscode:
code -a .
- Create configuration in root folder:
touch launch.json
{
"version": "0.2.0",
"configurations": [
{
"address": "10.233.97.254",
"localRoot": "${workspaceFolder}",
"name": "Attach to Remote",
"port": 9229,
"remoteRoot": "/usr/src/app",
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
]
}
Where address
is the IP of the container:
kubectl get endpoints galaxy -o=jsonpath='{.subsets[0].addresses[0].ip}'
-
Run debugger task 'Attach to Remote'
-
Set breakpoint and debug.