首次尝试调试项目时,Visual Studio Code 会提示选择调试器,然后生成 launch.json 文件。如何对生成的内容进行更改,以便不必手动调整每个新生成的 launch.json 文件?
例如,Rust 语言的 Cargo 将在 处创建一个经过检测的可执行文件./target/debug/[project name],但生成的 launch.json 将包含"program": "${workspaceFolder}/<your program>".
理想情况下,我可以指示 VS Code 在每次检测到 Cargo.toml 文件时生成经过调整的 launch.json。
我尝试将 Rust 特定的启动配置添加到我的用户设置中,但 VS Code 仍然生成未更改的 launch.json 文件。
我正在为 Visual Studio 代码编写一个扩展,我想在其中评估 javascript 调试会话的当前变量。当打开该部分下的调试窗格时,通常会显示这些变量VARIABLES。请参阅随附的屏幕截图。
我想在用户右键单击编辑器时访问这些变量,但我不知道如何操作。
我当前的扩展设置是这样的:在package.json我已经注册了一个菜单贡献和一个命令:
"contributes": {
"menus": {
"editor/context": [{
"command": "extension.showVariables",
"group": "navigation"
}]
}
}
Run Code Online (Sandbox Code Playgroud)
在我的 extension.ts 中,我注册了这样的命令:
export function activate(context: vscode.ExtensionContext) {
let disposable = vscode.commands.registerCommand('extension.showVariables', () => {
// TODO: let variables = vscode.debug.activeDebugSession.variables.toString();
vscode.window.showInformationMessage(variables);
});
}
Run Code Online (Sandbox Code Playgroud)
我试图让它们通过,vscode.debug.activeDebugSession但这里没有变量的 API。我还尝试注册一个事件处理程序,vscode.debug.onDidReceiveDebugSessionCustomEvent但我不知道在哪里搜索调试变量。
是否可以在 vs 扩展中访问这些变量,或者我是否需要实现自己的调试器?
我正在尝试在 VSCode 上调试量角器脚本。
我编辑了 launch.json 文件,但调试控制台抛出以下错误。
VSCode 调试控制台输出:
C:\Program Files\nodejs\node.exe --inspect-brk=45448 conf.js C:\Users\abc\AppData\Roaming\npm\node_modules\protractor\example/conf.js
Debugger listening on ws://127.0.0.1:45448/ab61a2d7-4b40-456b-86cb-838e94dfe5b0
Debugger attached.
Waiting for the debugger to disconnect...
Run Code Online (Sandbox Code Playgroud)
启动.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": "Protractor",
// "program": "${workspaceRoot}/node_modules/protractor/bin/protractor/example/conf.js",
"program": "${workspaceRoot}/conf.js",
"args": ["${workspaceFolder}/conf.js"],
"cwd": "${workspaceFolder}"
}]
}
Run Code Online (Sandbox Code Playgroud)
有没有可以在 VSCode 上调试量角器脚本的插件?
javascript automation protractor visual-studio-code vscode-debugger
我可以手动设置断点,并使用调试器运行,但我无法在 Rust 程序出现紧急情况时设置断点。如何在恐慌时设置断点,就像在 C++ 中设置异常一样?
我正在使用 Rust 1.29.0-nightly、VS Code 1.25.1 和 MSVC 2017 工具链。
debugging breakpoints rust visual-studio-code vscode-debugger
在阅读一些大型开源项目的代码时,如果有一个视图可以显示调试 JavaScript 时程序执行流程的可视化结果,那就太好了。那么有没有类似Code Map之类的调试JavaScript的工具呢?像这样: https: //dailydotnettips.com/did-you-know-code-map-can-be-used-to-visualize-the-call-stacks-directly
code-visualization code-map visual-studio-code vscode-debugger
我正在测试 VS Code 节点调试器,但在尝试附加到正在运行的进程时无法找到任何节点进程。
这是我的 launch.json 文件:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"processId": "${command:PickProcess}"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我的 package.json 文件的内容:
"scripts": {
"start": "node --inspect=0.0.0.0:9229 ./bin/www"
}
Run Code Online (Sandbox Code Playgroud)
使用“npm start”启动进程后,按“开始调试”,节点进程列表为:
看起来像这样,这些都不是我刚刚启动的服务器。即使我关闭节点服务器后,该列表仍然存在。
为什么我在 VSCode 进程附加中看不到任何正在运行的节点进程?
另外,我正在密切关注有关使用 VS Code 调试 Node.js 的教程。
我正在尝试在 VS Code 中建立一个简单的 React 前端和 NodeJS 后端并运行和调试。我正在使用复合启动配置来一起启动“客户端”和“服务器”。Nodejs 后端会自动为我启动,但我总是必须npm start在控制台中为客户端执行操作才能连接。我见过的所有教程都表明这一步必须在 VS Code 中运行调试配置之前进行。难道VS Code不能像NodeJS后端那样启动前端吗?
这是我的 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",
"compounds": [
{
"name": "Client+Server",
"configurations": [ "Server", "Client" ]
}
],
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Server",
"program": "${workspaceFolder}/server/server.js"
},
{
"type": "chrome",
"request": "launch",
"name": "Client",
"url": "http://localhost:3000",
"webRoot": …Run Code Online (Sandbox Code Playgroud) 我正在尝试在vs代码中调试节点脚本。
以下是我的launch.json-
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug sql report",
"program": "${workspaceFolder}/scripts/debug_sql.js"
}
]
}
Run Code Online (Sandbox Code Playgroud)
当我跑步时出现错误 Cannot find debug adapter for type 'node'.
我的代码版本是- Version 1.36.1 (1.36.1)
节点调试器以前可以工作。但不确定为什么现在不起作用。
任何想法如何解决这个问题?
我正在尝试调试附加到我的火狐浏览器。我的配置是:
{
"name": "Attach to Firefox",
"type": "firefox",
"request": "attach",
"port": 6000,
"pathMappings": [{
"url": "https://localhost:3000/",
"path": "${workspaceFolder}"
}],
"log": {
"fileName": "${workspaceFolder}/log.txt",
"fileLevel": {
"default": "Debug"
}
}
}
Run Code Online (Sandbox Code Playgroud)
未达到断点。
我正在面临同样的问题。
显然,我在启用调试服务器的情况下启动了 Firefox,并且 vscode 连接到:
firefox -start-debugger-server
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
浪费时间试图让 vscode 调试器在这个项目中运行。使用:
这个想法是生成一个与 ie11 兼容的纯香草 JS 组件。这是它的行动:

链接到现场示例:https : //gilsoncav.github.io/emails-tags-input/dist/index.html
链接到 repo:https : //github.com/gilsoncav/emails-tags-input
我在开发过程中使用 Live Server 扩展进行测试(但我怀疑该问题与此有关)。
当我尝试启动调试会话时,断点未“安装”。
我的package.json相关部分
"scripts": {
"dev": "webpack --mode development --watch",
"build": "webpack --mode production"
},
Run Code Online (Sandbox Code Playgroud)
我的webpack.config.js文件:
"scripts": {
"dev": "webpack --mode development --watch",
"build": "webpack --mode production"
},
Run Code Online (Sandbox Code Playgroud)
我的.vscode/launch.json:
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "chrome",
"url": "http://127.0.0.1:5500/dist/emails-input__form-example.html",
"webRoot": "${workspaceFolder}/dist",
"sourceMaps": true,
"trace": "verbose", …Run Code Online (Sandbox Code Playgroud) javascript typescript webpack visual-studio-code vscode-debugger
vscode-debugger ×10
debugging ×3
node.js ×3
javascript ×2
automation ×1
breakpoints ×1
code-map ×1
firefox ×1
protractor ×1
reactjs ×1
rust ×1
typescript ×1
webpack ×1