NodeJS Remote Debugging

R3zk0n · October 2, 2025

Contents
    1. Create a new mount point directory on your machine for the remote directory:
    $ sudo mkdir /mnt/debug
    
    1. 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
    
    1. Open the mounted folder with Visual Studio code:
    $ cd /mnt/debug
    $ code .
    
    1. Use SSH local port forwarding to get the remote node port on your machine:
    $ ssh -fNL 9229:127.0.0.1:9229 user@machine
    
    1. 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”: [ “/**" ], "type": "pwa-node" } ] }

    1. 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.

    2. When finished debugging, unmount the directory mount created in step 1:

      $ sudo umount /mnt/debug
      

    Twitter, Facebook