【问题标题】:Why is Visual Studio Code ignoring my tasks.json file?为什么 Visual Studio Code 会忽略我的 tasks.json 文件?
【发布时间】:2016-03-13 04:05:06
【问题描述】:

我对 tasks.json 有疑问,我已将其简化为以下内容。

在我的 Visual Studio Code 项目的根目录中,文件资源管理器侧边栏中清晰可见的根文件夹是 .vscode,而 .vscode 内部是 tasks.json。这是 VSCode 为我自动生成的,我没有移动文件夹或项目或将 VSCode 指向其他文件夹。

tasks.json的内容如下:

{
    "version": "0.1.0",

    // The command is tsc. Assumes that tsc has been installed using npm install -g typescript
    "command": "tsc",

    // The command is a shell script
    "isShellCommand": true,

    // Show the output window only if unrecognized errors occur.
    "showOutput": "silent",

    // args is the HelloWorld program to compile.
    "args": ["test.ts"],

    // use the standard tsc problem matcher to find compile problems
    // in the output.
    "problemMatcher": "$tsc"
}

请注意,"args" 的原始默认值是 ["HelloWorld.ts"],但我只是将其更改为 ["test.ts"]。

现在,当我按下 ctrl-shift-b 时,我得到以下信息:

错误 TS6053:找不到文件“HelloWorld.ts”。

请注意,每次尝试此操作时,我都会清除输出窗口中的输出。看起来 VSCode 忽略了我的 tasks.json 文件并使用了默认设置。

我在 Ubuntu 14.04 上。

【问题讨论】:

  • 完整性检查:您已保存文件?关闭/重新打开 VSCode?当您重新打开 tasks.json 时,它不会说 HelloWorld?您的项目中没有其他 .vscode 文件夹或 tasks.json 文件吗?
  • 电脑迟钝。我做了无数次所有这些事情。无论如何,在 VSCode 中运行构建会自动保存所有文件。我关闭了 VSCode,重新打开它,文件中仍然有 test.ts 而不是 HelloWorld.ts。无论我做什么,构建时都会出现相同的错误消息,一遍又一遍地破坏 .vscode 文件夹并重新创建它等等。然后我读了你的评论,翻了个白眼,决定重新启动我的整个系统出于恶意。 ;p 燃烧的火烈鸟,讨厌的 tasks.json 文件神秘地恢复并显示 ["HelloWorld.ts"]。我将其更改为 ["test.ts"] 并且效果很好。
  • VSCode/TypeScript 有没有其他的地雷你想让我准备好?

标签: typescript visual-studio-code


【解决方案1】:

听起来您遇到了一个奇怪的错误...如果您关闭并重新打开 Visual Studio 代码,这似乎不是问题所在?

我以前没有听说过这种错误发生。如果你继续得到它,请在 vscode github repo 上打开一个问题。

否则,我会假设这是通过重启解决的随机操作系统问题之一。

这就是为什么我称之为健全性检查。通常,像重启这样简单的事情可以解决很多奇怪的内存/ram 错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-31
    • 1970-01-01
    • 2015-07-10
    • 2017-04-18
    • 2016-02-16
    • 1970-01-01
    • 2014-06-15
    • 2017-09-06
    相关资源
    最近更新 更多