Debug NodeJS with Visual Studio Code on Windows and Linux
Windows
- Download Visual Studio Code
- Download and Install Node.JS
- Restart Visual Studio Code if it was opened
- Create a dummy file to test like hello.js with this content :
- In Visual Studio Code, open the folder containing this file above.
- From the left side of Visual Studio Code, double-click the file hello.js
- Click on the top bar menu "Debug". It should work.
Linux
This is a bit more tricky, but possible. The solution is to run an extra command-line to setup a SSH tunnel between the host (windows) and the target (linux)
- Download Visual Studio Code
- Download and Install Node.JS
- Restart Visual Studio Code if it was opened
- Create a test JS file to test like hello.js with this content :
- Upload the JS file on the linux box
- Run the JS file with debugger arguments:
- WINDOWS: Open a SSH tunnel on the machien with Visual Studio Code
Open a cmd.exe prompt and type :
$ ssh -L 9229:127.0.0.1:9229 maik@remote-node-host
References
https://maikthulhu.github.io/2019-05-17-remote-debugging-node-vscode/
Recent Comments