Skip to content

Instantly share code, notes, and snippets.

@acidtone
Last active October 10, 2022 22:39
Show Gist options
  • Save acidtone/5b121170ab2fb443c172af975b29c7ef to your computer and use it in GitHub Desktop.
Save acidtone/5b121170ab2fb443c172af975b29c7ef to your computer and use it in GitHub Desktop.
VS Code: Setting up the Debugger

VS Code: Setting up the Debugger

The VS Code Debugger can be tricky to work with until you set it up. There are a lot of options but the following code will allow you to run individual files:

Instructions

  1. Open the Run and Debug panel in VS Code;
  2. Create a launch.json file if one doesn't already exist; Run and Debug menu screencap
  3. Add a "Run Current File" configuration by adding it to your launch.json file:
{
  // 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": [
    {
      // Other existing configurations...
    },
    // Add this configuration to your launch.json file 
    {
      "name": "Run Current File",
      "program": "${file}",
      "request": "launch",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "type": "node"
    }
  ]
}
  1. Try running hello.js (included in this gist) in the debugger to confirm it works;
console.log('Hello World!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment