我在Visual Studio代码中有一个调试设置,我运行一个外部二进制文件,可以执行我的JS文件(使用duktape).调试适配器当前只支持附加请求(不启动),所以我必须在调试JS脚本之前运行二进制文件.
为了避免必须手动启动应用程序,我为它创建了一个任务,并在我的launch.json文件中设置它:
{
"version": "0.2.0",
"configurations": [{
"name": "Attach MGA",
"type": "duk",
"preLaunchTask": "debug mga",
"request": "attach",
"address": "localhost",
"port": 9091,
"localRoot": "${workspaceRoot}",
"stopOnEntry": false,
"debugLog": true
}]
}
Run Code Online (Sandbox Code Playgroud)
任务定义如下:
{
"version": "0.1.0",
"command": "<absolute path to>/mga",
"isShellCommand": false,
"showOutput": "always",
"suppressTaskName": true,
"tasks": [{
"taskName": "debug mga",
"args": ["--debugger", "main.json"]
}]
}
Run Code Online (Sandbox Code Playgroud)
现在问题是vscode等待预启动任务完成,而应用程序等待调试器附加.赶上22.
如何避免vscode等待预启动任务完成?
更新:
与此同时,我已经阅读了vscode任务页面,并提出了此任务配置.不过,它对我不起作用
{
"version": "2.0.0",
"tasks": [
{
"label": "launch-mga",
"type": "shell",
"command": "<absolute path to>/mga",
"args": [
"config/main.json",
"--debugger"
], …Run Code Online (Sandbox Code Playgroud) 每当我尝试打开我的 VS Code 编辑器时,什么也没有发生,它无法启动,甚至没有错误..!! 我很困惑我的 vs 代码出了什么问题。请任何人帮我解决它..!!
以下是我在终端中输入的详细命令。
C:\Users\Avinash>code . --verbose
[main 2020-05-10T05:17:56.317Z] Error: UNKNOWN: unknown error, mkdir
[main 2020-05-10T05:17:56.318Z] Lifecycle#kill()
[main 2020-05-10T05:17:56.320Z] [File Watcher (node.js)] Error: UNKNOWN: unknown error, stat 'c:\Users\Avinash Maurya\AppData\Roaming\Code\User'
Run Code Online (Sandbox Code Playgroud) 我创建了一个新的Angular 6 CLI项目
ng new myProjects
Run Code Online (Sandbox Code Playgroud)
创建'子项目'
ng g mySubProject
Run Code Online (Sandbox Code Playgroud)
如果我服务mySubProject然后尝试使用我的正常launch.json从VS代码调试,然后没有命中断点.
{
"name": "Launch Chrome (test)",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200/",
"webRoot": "${workspaceFolder}"
},
Run Code Online (Sandbox Code Playgroud)
有人可以指导我如何设置我的launch.json来调试像这样的子项目吗?
(有关如何设置子项目的详细信息,请基于此处的帖子 )
如果我只是服务,那么这个launch.json负责'主'项目OK - 所以我猜我需要在launch.json中设置某个地方告诉它子项目在哪里?
在最近更新 Visual Studio Code 之前,我能够使用此launch.json配置调试用 TypeScript 编写的 Node.js 应用程序
{
// 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": "Debug API",
"protocol": "inspector",
"program": "${workspaceFolder}/apps/api/src/main.ts",
"outFiles": ["${workspaceFolder}/dist/apps/api/main.js"],
"sourceMaps": true
}
]
}
Run Code Online (Sandbox Code Playgroud)
但现在我收到这个错误
import * as express from 'express';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1054:16)
at Module._compile (internal/modules/cjs/loader.js:1102:27)
at …Run Code Online (Sandbox Code Playgroud) 我在使用 VS code 进行调试时遇到问题。我已经为 vs code 扩展安装了 python 并重新加载了几次。但是当我尝试在调试模式下运行时,出现以下错误
The debug type is not recognized. Make sure that you have a corresponding debug extension installed and that it is enabled.
Run Code Online (Sandbox Code Playgroud)
我的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": [
{
"name": "Python : Fichier actuel",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
Run Code Online (Sandbox Code Playgroud)
可能是什么问题?
我正在研究自监督机器学习代码。
我想用python debuggernot来调试代码pdb.set_trace()。这是 ubuntu 终端的 python 命令。
python -m torch.distributed.launch --nproc_per_node=1 main_swav.py \
--data_path /dataset/imagenet/train \
--epochs 400 \
--base_lr 0.6 \
--final_lr 0.0006 \
--warmup_epochs 0 \
--batch_size 8 \
--size_crops 224 96 \
--nmb_crops 2 6 \
--min_scale_crops 0.14 0.05 \
--max_scale_crops 1. 0.14 \
--use_fp16 true \
--freeze_prototypes_niters 5005 \
--queue_length 380 \
--epoch_queue_starts 15\
--workers 10
Run Code Online (Sandbox Code Playgroud)
为了使用 VScode 调试代码,我尝试修改 launch.json,如下所示,参考stackoverflow 问题
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: …Run Code Online (Sandbox Code Playgroud) 我在调试 Angular 应用程序时遇到 VS Code 调试器问题。我有一个由ng new命令生成的干净的 Angular 应用程序。我在该函数中添加了几行代码ngOnInit。
我想启动 chrome 调试器。浏览器启动成功,但应用程序未加载。我只能看到空白页面,加载程序仍在旋转,开发控制台完全是空的。请参阅随附的屏幕截图。
几天前一切都运转良好。该应用程序使用命令启动npm start,包 json 进行了唯一的修改 - host 更改为127.0.0.1。该应用程序在正常浏览器窗口中正常工作(无调试模式)。
我使用 macOS,最新的 macOS Ventura 版本。
有人可以帮忙解决这个问题吗?
这是我的launch.json文件:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://127.0.0.1:8080",
"webRoot": "${workspaceFolder}",
}
]
}
Run Code Online (Sandbox Code Playgroud)
浏览器:
未加载 DOM,网络选项卡也为空(仅向 127.0.0.1 发出单个请求,但没有响应。

我已重新启动 VS Code,并安装了最新更新。操作系统也一样。我尝试过不同的角度应用程序,结果相同。我也尝试过与 8080 不同的端口,但没有成功。
如何在nodejs调试控制台中更改对象实例的字符串表示形式.有没有一种方法(比如toString()在.NET中)我可以覆盖?
请考虑以下代码:
class SomeObject{
constructor(){
this._varA = "some text";
this._varB = 12345;
this._varC = "some more text";
this._varD = true;
this._varE = 0.45;
}
toString(){
return "custom textual rapresentation of my object";
}
}
var array = [];
array.push(new SomeObject());
array.push(new SomeObject());
array.push(new SomeObject());
console.log(array);
Run Code Online (Sandbox Code Playgroud)
但是在我工作的其他环境和编程语言中,覆盖该toString()方法将显示toString()(在上面的示例中"custom textual representation of my object")的结果,而不是调试器创建的动态文本表示(在上面的示例代码中是SomeObject {_varA: "some text", _varB: 12345, _varC: "some more text", …}:) - 我不知道如果没有定义自定义替代方案,那么在一分钟内它是非常有用的.
我也意识到这console.log(array.toString());甚至console.log(array.map(t=>t.toString()));会产生类似于我所追求的东西,但是这会阻止我使用调试导航来浏览对象,即.钻入对象图.
如果这是不可能的,其他人会从中受益吗?如果有足够的兴趣,我可以考虑定义和实现它作为一个功能.
javascript debugging node.js visual-studio-code vscode-debugger
在检查 API 端点(确定连接状态)的相对简单的代码块中,我依靠 atry..catch作为机制来验证应用程序是否可以与服务器通信。
我遇到的问题是,在调试时,调试器总是在连接线上停止(当应用程序离线时),即使我在内部处理错误。
Future<bool> isOnline() async {
try {
// VSCode debugger always stops on this line when no connection
await http
.get('${consts.apiBaseUrl}/api/ping')
.timeout(Duration(seconds: normalTimeoutLength))
.catchError(
(_) {
// Trying catchError on the Future
_isOnline = false;
return false;
},
);
_isOnline = true;
return true;
} on HttpException catch (_) {
// Trying to catch HTTP Exceptions
_isOnline = false;
return false;
} on SocketException catch (_) {
// Trying to catch Socket Exceptions
_isOnline …Run Code Online (Sandbox Code Playgroud) 我不知道如何在调试控制台中按 Enter 键使自动完成功能发挥作用。这非常烦人,因为它在代码窗口中工作,但不在调试控制台中工作(只有选项卡自动完成在那里工作)。
也许我可以调整一些设置?
请帮忙,这太烦人了。
vscode-debugger ×10
debugging ×3
angular ×2
vscode-tasks ×2
dart ×1
exception ×1
flutter ×1
javascript ×1
node.js ×1
python ×1
python-3.x ×1
pytorch ×1