Reputation: 91
I am trying to set up VScode to debug a remote nodejs app on a Raspberry Pi 4. I use VScode - Insiders and the Remote Development extension with Remote - SSH (nightly). The SSH connection works perfectly fine and I can debug remote Python programs easily. When I launch a nodejs program (test.js) nothing happens. In the debug console I only see: /usr/bin/node test.js
and then nothing happens. I can execute the same line in the VScode terminal and it runs as expected.
My launch config is below, node debug is available on the remote.
Can someone please help me out?
{
"name": "Launch Program",
"program": "${workspaceFolder}/test.js",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
Upvotes: 7
Views: 969
Reputation: 613
In the following example your project will reside on your server in /path/to/my/project and your application will be called index.js.
Navigate to your project:
cd /path/to/my/project/
Run your application, activating the inspector by setting the --inspect
parameter to the port you will tunnel into from your local system:
node --inspect=0.0.0.0:9229 ./index.js
Set up an SSH tunnel to your server (replace [email protected]
with your user name and the address of your server):
ssh -L 9221:localhost:9229 [email protected]
The server's port 9229 is now mapped to your localhost on port 9221.
In VS Code add the following configuration:
{
"type": "node",
"request": "attach",
"name": "Debug remote",
"protocol": "inspector",
"address": "localhost",
"port": 9221,
"sourceMaps": true,
"localRoot": "${workspaceFolder}",
"remoteRoot": "/path/to/my/project/"
}
Set break points in your code and launch the "Debug remote" configuration in VS Code.
The code will now stop on your break points when you load a request in a browser.
Upvotes: 4