Skip to content

Instantly share code, notes, and snippets.

@brunojppb
Created September 1, 2022 16:55
Show Gist options
  • Save brunojppb/9cbc099de7ffdb13703e740c2e3cdebf to your computer and use it in GitHub Desktop.
Save brunojppb/9cbc099de7ffdb13703e740c2e3cdebf to your computer and use it in GitHub Desktop.

Debugging NodeJS projects via VS Code

create a launch config under .vscode with the following:

// .vscode/launch.json
{
  // 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": [
    {
      "name": "Attach to Goldfish",
      "cwd": "${workspaceFolder}/packages/servers",
      "type": "node",
      "request": "attach",
      "port": 9229
    }
  ]
}

Now just run the node process normally via the terminal and then go to Run > Start debugging. This is going to attach the debugger the the running node process on port 9229.

Make sure to start the node process with --inspect, otherwise the debugger won't be able to be attached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment