64

When debugging in vscode I'd like to make some "blackboxing" and do not enter into code I didn't write. How can I do this?

1
  • Did we collectively stop calling it 'blackboxing' as of 2023 because of racial injustice? Seems like the word 'blackbox' isn't used in any of the developer tools at this point.
    – fivestones
    Jun 13, 2023 at 6:54

9 Answers 9

79

In your launch or attach debug task you can enter a

"skipfiles"

option which is

"An array of file or folder names, or path globs, to skip when debugging."

For example, from skipping node internals during debugging

"skipFiles": [
  "${workspaceFolder}/node_modules/**/*.js",
  "${workspaceFolder}/yourLibToSkip/**/*.js"
]

Also, there is a "magic reference" to the built-in core node modules you can use:

"skipFiles": [
  "<node_internals>/**/*.js"
]
8
  • 1
    could you kindly provide some example, I still cannot prevent entering to different dependencies folders inside of "node_modules" folder (i.e. ./node_modules/react-dom/lib/...), when debugging . part of launch task is "skipFiles":"[./node_modules/**]"
    – Pavel L
    Dec 3, 2017 at 10:53
  • 1
    @d2048 See my edits to the answer and the included link.
    – Mark
    Dec 3, 2017 at 15:29
  • This doesn't work for flutter. Can you please show us the full example for flutter please? This looks like for javascript Jun 20, 2020 at 19:43
  • 20
    That "magic reference" doesn't work. I've downloaded VSCode today, debugged a TypeScript project, and am still ending up in async_hooks.js. Jul 1, 2020 at 22:17
  • 7
    Although "skipFiles":["<node_internals>/**"] works for debug sessions which are NOT attached, it doesn't seem to work in case of attaching a process. Jul 13, 2020 at 17:38
14

I was confused on where to put the setting, so just in case, if you want to skip both node_modules deps and node_internals files, your .vscode/launch.json file should look something like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Tests",
            "type": "node",
            "request": "launch",
            ...
            "skipFiles": ["<node_internals>/**", "${workspaceFolder}/node_modules/**/*.js"]
        }
    ]
}
3
  • 1
    This was the answer that worked for me debugging a ReactJS app using Chrome on Windows.
    – ggariepy
    Oct 6, 2021 at 16:14
  • I was trying with lots of other answers to this question and none of them worked. Turns out my problem was that I had skipFiles as a sibling to configurations instead of as a child. This fixed it for me. Thanks!
    – fivestones
    Jun 13, 2023 at 6:52
  • thank you for showing me exactly where to place skipFiles in the file. The other refs don't explain this.
    – quilkin
    Oct 14, 2023 at 7:43
3

Only this worked for me.

"debug.javascript.terminalOptions": {
    "skipFiles": [
        "<node_internals>/**"
    ]
}
2

For Typescript built with Webpack, I had to put the exclusions in launch.json - putting them in settings.json/terminalOptions had no effect.

Also, I had to exclude the pattern of the generated files, not the source files. In my case it looks like:

"skipFiles": [
    "<node_internals>/**",
    "**/vendors-*",
],
1

Just to amplify on Mauro Aguilar's correct answer, here are the complete contents of my launch.json file. Note that I am debugging a ReactJS app (circa 2021) with VS Code 1.60.2 on Windows 10 using Chrome v.94. If you're using a Linux machine or a Mac, YMMV.

{
    // 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": "pwa-chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceFolder}",
            "skipFiles": ["<node_internals>/**/*.js", "${workspaceFolder}/node_modules/**/*.js"]
        },
    ]
}
1

For flutter apps, add to your user settings the following:

"debugExternalPackageLibraries": false,
"dart.debugSdkLibraries": false,
0

this is my launch.json file (it works for me):

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "edge",
            "request": "launch",
            "name": "Launch Edge against localhost",
            "url": "http://localhost:4200",
            "webRoot": "${workspaceFolder}",
            "skipFiles": [
              "${workspaceFolder}/node_modules/**/*.js"
            ]
        }
    ]
}
0

For some reason, I've needed to add both types of skip file entries,

  "skipFiles": [
    "${workspaceFolder}/node_modules/**/*.js",
    "<node_internals>/**"
  ],

This seems to have resolved the issue.

0

It depends on the language/debug-support extension. VS Code does not have a generalized way to do this because languages differ in the ways that they describe programs in source and object/binary formats, and in the ways that their backing debug tooling support skipping things in debugging.

1
  • Normally I'd vote to close such a question as lacking focus. But people on meta have gotten cross at me for doing that on well-established questions... Also, I have no idea what to do about stackoverflow.com/q/52980448/11107541, which seems to have been interpreted by the community just as broadly despite being about C#.
    – user
    Dec 8, 2023 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.