【问题标题】:Cannot use TSC - Error reading file "anything.ts": File not found无法使用 TSC - 读取文件“anything.ts”时出错:找不到文件
【发布时间】:2012-09-30 04:00:09
【问题描述】:

无论我做什么,我都无法让 TSC Typescript 编译器找到任何文件。我已经尝试过 Visual Studio Extension 附带的 tsc 和 npm 附带的 tsc。我在 Node.js 命令行 windows shell 和 Git Bash shell 中尝试过。不管我做什么,它只是说找不到文件。我读过编译器只适用于 .ts 和 .str 文件,但这似乎不是问题。

这是我所看到的一个简单示例。我知道这些文件将是空的,但我已经用包含代码的文件尝试了所有这些,它并没有改变任何东西。

C:\>touch test.ts

C:\>ls *.ts
test.ts

C:\>tsc test.ts
Error reading file "test.ts": File not found

C:\>tsc C:\test.ts
Error reading file "C:\test.ts": File not found

C:\>touch test.str

C:\>tsc test.str
Error reading file "test.str": File not found

C:\>tsc ./test.str
Error reading file "./test.str": File not found

C:\>tsc ./test.ts
Error reading file "./test.ts": File not found

C:\>touch test.js.ts

C:\>tsc test.ts
Error reading file "test.ts": File not found

C:\>tsc test.js
Error reading file "test.js": File not found

【问题讨论】:

    标签: npm typescript tsc


    【解决方案1】:

    恐怕 TSC 在空文件上会以这种方式失败。

    【讨论】:

    • 是的,就是这样,我想我不小心清空了我的另一个测试文件。
    【解决方案2】:

    看起来像当前编译器 [0.8] 中的一个错误,tsc 不应该在空文件上失败。不过

    我知道这些文件将是空的,但我已经用包含代码的文件尝试了所有这些,它并没有改变任何东西。

    我有点担心这部分。还是这样吗?

    【讨论】:

      【解决方案3】:

      这很难从远处调试。打字稿编译器在解析文件之前会进行大量处理。

      运行的输出是什么

      tsc -debug test.ts
      

      ?另外,请确保 test.ts 不为空。

      【讨论】:

        猜你喜欢
        • 2020-12-20
        • 1970-01-01
        • 2019-01-02
        • 1970-01-01
        • 2022-12-06
        • 2013-04-17
        • 2018-12-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多