Let’s say I have a NodeJS application running on AWS — Amazone Web Service. I want to remotely debug the server-side NodeJS application using native Visual Studio Code.

The Visual Studio Code debug configuration defines two types, attach and launch. Visual Studio Code’s official documentation explains these two debug startup behaviors:

The best way to explain the difference between launch and attach is think of a launch configuration as a recipe for how to start your app in debug mode before VS Code attaches to it,

Launch simply means to Launch the app in Debug mode.

While an attachconfiguration is a recipe for how to connect VS Code’s debugger to an app or process that’s alreadyrunning.

Attach means to bind Visual Studio Code’s debugger to an already running application.

Since my requirement was to use native Visual Studio Code to debug the nodeJS application running on AWS, Attach was the obvious choice. Click the Debug Configuration button:

The launch.json file with debugging configuration information is automatically displayed:

Replace the contents of launch.json with the following:

{
    // 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": [{"type": "node"."request": "attach"."name": "Jerry's first debug config"."address": "127.0.0.1"."port": 9221}}]Copy the code

The implication of this configuration file is to tell Visual Studio Code’s debugger to connect to the application debugger on 127.0.0.1:9221 to debug.

Of course, the last step is to bind the local 127.0.0.1:9221 to the AWS debugger using SSH.

ssh -i C:\Users\i042416.ssh\KOI.pem -L 9221:localhost:9229 [email protected]

With everything in place, do an action that triggers the execution of the NodeJS application on AWS. For example, I have a NodeJS application deployed on AWS as a Webhook for my Github Repository. Every time I create an issue in the repository, Github pushes an event to my Webhook.

Now I’ve created an issue called Test Create Issue, and once I hit the Close button,

This issue Close event is automatically sent to my AWS application and as you can see below the breakpoint is triggered so THAT I can remotely debug my AWS application using native Visual Studio Code.

For more of Jerry’s original articles, please follow the public account “Wang Zixi “: