【问题标题】:configuring tasks.json in visual code在可视化代码中配置 tasks.json
【发布时间】:2017-04-15 13:12:28
【问题描述】:

尝试配置tasks.json,使其能够转译和运行 JS 代码。但不知道该怎么做。 此外,每当我尝试 (Ctrl+Shift+B) 时,VS 代码都会告诉我:

tasks.json 中没有任务被标记为构建任务。使用“isBuildCommand”标记任务

tasks.json

{
    "version": "0.1.0",
    "command": "tsc",
    "isShellCommand": true,
    "showOutput": "silent", 
    "isBuildCommand": true,
    "args": ["--target", "ES5",
         "--outDir", "js",
         "--sourceMap",
         "--watch",
         "app.ts"],
    "problemMatcher": "$tsc"
}

【问题讨论】:

  • 我看不出配置有什么问题。你的tasks.json 文件在.vscode 文件夹中吗?
  • 是的,它在 .vscode 文件夹中
  • 刚刚重置了 Windows,我也遇到了这个问题(我以前从未遇到过)。我相信这应该是某种错误。

标签: typescript visual-studio-code


【解决方案1】:

您似乎错过了配置中的 tasks 数组。这是来自documentation的示例

{
    "version": "0.1.0",
    "command": "echo",
    "isShellCommand": true,
    "args": [],
    "showOutput": "always",
    "echoCommand": true,
    "suppressTaskName": true,
    "tasks": [
        {
            "taskName": "hello",
            "args": ["Hello World"]
        },
        {
            "taskName": "bye",
            "args": ["Good Bye"]
        }
    ]
}

在你的情况下,它可能是这样的。

{
    "version": "0.1.0",
    "command": "tsc",
    "isShellCommand": true,
    "tasks":[
        {
           "isBuildCommand": true,
           "args": ["--target", "ES5",
                    "--outDir", "js",
                    "--sourceMap",
                    "--watch",
                    "app.ts"],
           "problemMatcher": "$tsc",
           "showOutput": "silent"
        }
}

【讨论】:

    【解决方案2】:

    似乎是一个错误。

    关闭再重新打开窗口暂时解决了。

    https://github.com/Microsoft/vscode/issues/24796

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-12
      • 2010-11-19
      • 2010-11-10
      • 2012-06-26
      • 2012-10-14
      • 2021-09-29
      • 1970-01-01
      • 2022-01-21
      相关资源
      最近更新 更多