【发布时间】:2018-05-13 09:08:52
【问题描述】:
在 vscode 中调试时,我想做一些“黑盒”,不要输入我没有编写的代码。我该怎么做?
【问题讨论】:
标签: debugging visual-studio-code
在 vscode 中调试时,我想做一些“黑盒”,不要输入我没有编写的代码。我该怎么做?
【问题讨论】:
标签: debugging visual-studio-code
在您的启动或附加调试任务中,您可以输入一个
“跳过文件”
选项是
“调试时要跳过的文件或文件夹名称或路径 glob 的数组。”
例如,来自skipping node internals during debugging
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js",
"${workspaceFolder}/yourLibToSkip/**/*.js"
]
此外,您可以使用内置核心节点模块的“魔法参考”:
"skipFiles": [
"<node_internals>/**/*.js"
]
【讨论】:
"skipFiles":"[./node_modules/**]"
async_hooks.js。
"skipFiles":["<node_internals>/**"] 适用于未附加的调试会话,但在附加进程的情况下似乎不起作用。
我对设置设置的位置感到困惑,所以以防万一,如果您想同时跳过 node_modules deps 和 node_internals 文件,您的 .vscode/launch.json 文件应该如下所示:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Tests",
"type": "node",
"request": "launch",
...
"skipFiles": ["<node_internals>/**", "${workspaceFolder}/node_modules/**/*.js"]
}
]
}
【讨论】:
只有这对我有用。
"debug.javascript.terminalOptions": {
"skipFiles": [
"<node_internals>/**"
]
}
【讨论】:
这是我的 launch.json 文件(对我有用):
{
"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"
]
}
]
}
【讨论】:
对于 Flutter 应用,将以下内容添加到您的用户设置中:
"dart.debugExternalLibraries": false,
"dart.debugSdkLibraries": false,
【讨论】:
为了扩大 Mauro Aguilar 的正确答案,这里是我的 launch.json 文件的完整内容。请注意,我正在使用 Chrome v.94 在 Windows 10 上使用 VS Code 1.60.2 调试 ReactJS 应用程序(大约 2021 年)。如果您使用的是 Linux 机器或 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"]
},
]
}
【讨论】: