node.js - Debugging a node app hosted on a VM using Visual Studio Code -


i'm looking little in debugging app using visual studio code, app held in virtual machine hosted oracle virtual box.

the vm has been provisioned typical setup of node, express, node-inspector etc. , able debug app using node-inspector (i.e. port node-inspector has been forwarded within vm , if set app running "node --debug-brk app.js" listens on port 5858 , can navigate localhost:8080/debug?port=5858 start debugging).

however in vsc if use "attach" option in debug cannot breakpoint @ all.

is there special missing here or there log files can @ - i'm on osx yosemite , vm os running in virtual box headless opensuse, provisioned vagrant?

nb: have tried telnetting vm on port 5858 , different response within vm local machine itself, indicated below:

inside vm:

telnet 127.0.0.1 5858 trying 127.0.0.1... connected 127.0.0.1. escape character '^]'. type: connect v8-version: 3.14.5.9 protocol-version: 1 

embedding-host: node v0.10.32 content-length: 0

outside vm:

telnet 127.0.0.1 5858 trying 127.0.0.1... connected localhost. escape character '^]'. connection closed foreign host. 

any appreciated?


yes i'm running vscode outside vm - vm headless.

the ports configured forwarded inside vagrant provisioning script. colleague has informed me there might company policy being forced upon relating our network adapters - preventing/causing connection issue.

however i've tried different approach. i've tunnelled connection via ssh traffic on port 5858:

ssh -i myprivatekey -l 5858:localhost:5858 tempuserlocalhost -p 2222  

now when start debugging app (i.e. node --debug app.js) , use attach option debugger attaches. doesn't hit breakpoint in app.js though, when should do.

in actual fact if pause debugger list of local variables , call stack following error shown:

error opening 'app.js' (file not found) 

note: app.js , other code files not held on vm, held on local machine samba shares configured accordingly. perhaps causing confusion?

i have verified tunnelling port 5858 via ssh works in far can connect node running inside vm , use debugger functionality not involve source paths (source paths used breakpoints , step events, etc.) problem source paths vscode needs access source files same paths node running inside vm. if share source through samba, absolute path leading file might different between inside of vm , outside. workaround vscode preview make paths identical e.g. introducing (symbolic) links etc. have create bug on our side improve source path matching.

andre weinand, visual studio code


Comments