如何修复Dart launch.json文件中的错误?

wxclj1h5  于 2023-05-30  发布在  其他
关注(0)|答案(1)|浏览(176)

我正在学习一些关于 dart 输入的教程,但似乎它只能在终端中运行。不幸的是,我一直得到这个错误**.vscode/launch.json:1:1:错误:应为声明,但得到“|”。{ ^**这是我的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": "Dart & Flutter",
            "request": "launch",
            "type": "dart",
            "program": ".vscode/launch.json",
            "console": "externalTerminal"   
        }
    ]
}

下面是code --list - extensions的输出:

adelphes.android-dev-ext
Dart-Code.dart-code
Dart-Code.flutter
eamodio.gitlens
esbenp.prettier-vscode
formulahendry.code-runner
jeff-hykin.better-cpp-syntax
ms-azuretools.vscode-docker
ms-vscode-remote.remote-containers
ms-vscode-remote.remote-wsl
ms-vscode.cmake-tools
ms-vscode.cpptools
ms-vscode.cpptools-extension-pack
ms-vscode.cpptools-themes
PKief.material-icon-theme
streetsidesoftware.code-spell-checker
timkmecl.codegpt3
twxs.cmake
VisualStudioExptTeam.vscodeintellicode
lsmepo6l

lsmepo6l1#

program字段应该是一个Dart脚本,但您将其设置为launch.json本身:

"program": ".vscode/launch.json",

这应该是类似于"lib/main.dart""bin/main.dart"
如果你想让Dart扩展从打开的文件/工作区中推断出"program",你也可以完全删除它(如果打开的文件在bin/tool/test/中,它会运行它,否则它会查找一些常见的文件,如bin/main.dart)。

相关问题