I would like to be able to debug an application through VSCode via SSH. So far I have create the debug configuration in VSCode and I have created a SSH tunnel on the correct port.
So far, this works fine. I can connect to the remote application using node inspect <host>:<port> and I can attach via VSCode. I have veryfied both using the Dabugger attached. log line in the remote application.
However, things start to break when I actually use the VSCode debugger. I.e. if a breakpoint should be triggered, I get an error instead. This is because the application tries to require a module that is anly available on my local machine and not the remote one:
My guess is that this is because VSCode does not even know that it is being tunnled to a different machine and still assumes that it is on my local machine. Are there any ways to solve this?
By the way, this is my launch configuration:
{
"name": "Debug Docker",
"type": "node",
"request": "attach",
"address": "localhost",
"restart": true,
"port": 9228,
"localRoot": "${workspaceFolder}/dist",
"remoteRoot": "/app/dist",
"presentation": {
"order": 1
},
"skipFiles": ["<node_internals>/**/*.js"]
}
And this is the SSH Tunnel command:
ssh -nNT -L 9228:localhost:9229 remote-system.example.org
