-
Launch the node process in the VM with --debug-brk flag. This will break the execution of the node process in the start.
node --debug-brk <app.js> <args>
. Node.js versions >= 6.3 support new inspector protocol:node --inspect <app.js> <args>
-
Create a launch config in VS Code with a mapping from the VM file system to the local file system
{
"name": "Attach node",
"type": "node",
"request": "attach",
"address": "localhost",
"port": 5858,
"localRoot": "<cwd path in local file system>",
"remoteRoot": "<cwd path in VM file system>"
}
Or with new inspector protocol:
{
"name": "Attach node",
"type": "node",
"request": "attach",
"address": "localhost",
"port": 9229,
"protocol": "inspector",
"localRoot": "<cwd path in local file system>",
"remoteRoot": "<cwd path in VM file system>"
}
- Attach to the running node process using the launch config