- Create a new mount point directory on your machine for the remote directory:
$ sudo mkdir /mnt/debug
- Remote mount the directory of the remote application on your machine (to avoid having to copy all of the remote files to your machine):
$ sudo sshfs -o allow_other,default_permissions user@machine:/path/to/program /mnt/debug
- Open the mounted folder with Visual Studio code:
$ cd /mnt/debug
$ code .
- Use SSH local port forwarding to get the remote node port on your machine:
$ ssh -fNL 9229:127.0.0.1:9229 user@machine
- Create a NodeJS debugging launch.json file and add remote debugging configuration: Example:
Code:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
“version”: “0.2.0”,
“configurations”: [
{
“address”: “127.0.0.1”,
“localRoot”: “${workspaceFolder}”,
“name”: “Attach to Remote”,
“port”: 9229,
“remoteRoot”: “/path/to/remote/application/folder”,
“request”: “attach”,
“skipFiles”: [
“
-
Start the debugger and set breakpoints to start debugging. Note Breakpoints might appear as a gray circle for a few seconds after you initially place them if the remote debugger is still in the process of attaching, but they’ll fill in red once that’s complete.
-
When finished debugging, unmount the directory mount created in step 1:
$ sudo umount /mnt/debug
