【问题标题】:error TS6231: Could not resolve the path '' with the extensions: '.ts', '.tsx', '.d.ts'错误 TS6231:无法使用扩展名解析路径“”:“.ts”、“.tsx”、“.d.ts”
【发布时间】:2021-10-28 09:50:36
【问题描述】:

我正在使用 typescript 处理 firebase 函数,并且在运行 tsc . -watch 时控制台中出现此错误:

[12:19:41 PM] Starting compilation in watch mode...

error TS6231: Could not resolve the path '' with the extensions: '.ts', '.tsx', '.d.ts'.
  The file is in the program because:
    Root file specified for compilation

[12:19:45 PM] Found 1 error. Watching for file changes.

我不知道这可能是从哪里引起的。自上次运行以来,我没有更改任何内容。

有什么解决办法吗?

【问题讨论】:

  • 您使用的是哪个版本的节点? 16 个中的 14 个?

标签: javascript typescript firebase function


【解决方案1】:

试试tsc -watch,它为我解决了这个问题

【讨论】:

    【解决方案2】:

    我看到了同样的错误,它掩盖了真正的错误。

    尝试一步编译你的打字稿,然后作为第二步运行入口文件。所以本质上,处于观看模式。


    FWIW,对我来说实际发生的错误是代码无法读取我的环境变量。我追踪到来自dotenv 的更新,broke the abilityNODE_ENV 在我的启动脚本中正确设置(在 Windows 机器上)。

    【讨论】:

      猜你喜欢
      • 2019-07-12
      • 2021-08-27
      • 1970-01-01
      • 2017-02-01
      • 2021-02-24
      • 2020-11-18
      • 2015-12-16
      • 1970-01-01
      • 2020-05-02
      相关资源
      最近更新 更多