debugging the current file in vs code

2020-04-25

 | 

~1 min read

 | 

124 words

When I have very modularized applications and want to be able to debug a single file, it’s useful to be able to switch from a workspace context to debug just that file.

This is a one line change in the launch.json of VS Code.

Where a configuration may have been:

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": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "skipFiles": ["<node_internals>/**"],
-     "program": "${workspaceFolder}/start",+     "program": "${file}",      "outFiles": ["${workspaceFolder}/**/*.js"]
    },
  ]
}

Now, to invoke the Debugger, navigate to the Run explorer (⇧ + ⌘ + D) and select “Launch Program” (or press fn5).


Related Posts
  • Debugging Typescript In VS Code


  • Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!