NTVS Remote Debugging (Windows, Linux, Mac)
Node.js Tools for Visual Studio (NTVS) supports attaching to and debugging Node.js processes running behind the remote debugging proxy (RemoteDebug.js). The proxy is necessary to expose the Node.exe debugger port from the target host to the NTVS debugger. Node.exe only exposes its debugger port to the local host where it is running. The remote debug proxy exposes the local port through a remotely accessible port.
Starting NTVS remote debugging requires both preparing the target host, and attaching the NTVS debugger to the remote Node.exe process.
Target Host Preparation
Preparing a target host for remote debugging is as simple as running your target Node.exe behind the remote debug proxy, on the remote host. Where you would normally start a Node.exe process directly with:
node.exe script.js
Instead start the Node.exe process with the remote debug proxy, passing it the script to be remotely debugged:
node.exe RemoteDebug.js script.js
The remote debug proxy (RemoteDebug.js) can be found in the folder opened using the 'Tools\Node.js Tools\Remote Debug Proxy' menu.
By default the remote debug proxy proxies a Node.exe debugger to port 5858 on the remote host. This can be configured using the remote debug proxy command line arguments:
node.exe RemoteDebug.js -machineport 5860 script.js
For configuration details, consult the remote debug proxy help, viewed by running it with the -help command line argument:
node.exe RemoteDebug.js -help
Note: The remote debug proxy's host debugger port, default (5858) or configured, must be accessible to the machine attaching the NTVS debugger.
Attaching the NTVS debugger
Attaching the NTVS debugger entails walking through the VS "Attach to process" UI. The steps are as follows:
1. Launch the "Attach to process" dialog from the 'Debug\Attach to Process' menu
2. For 'Transport', choose 'Node remote debugging'
3. For 'Qualifier', provide the target host and debugger port (ex. myhost:5858) and hit enter
4. In 'Available Processes' choose the target node.exe process
5. Choose 'Attach'
Local Attach
It is also possible to attach to locally running Node.exe processes, if they were started with debugging enabled, using the '--debug' command line argument:
node.exe --debug server.js
To attach to such local Node.exe processes, Follow the attach instructions above, providing localhost:5858 for 'Qualifier'.
Note: It is possible to run Node.exe with a non-default local debugger port. This is accomplished by providing the desired port with the '--debug' command line argument:
node.exe --debug:5860 server.js