ERR_REQUIRE_ASYNC_MODULE


当尝试 require() 一个 ES 模块 时,模块结果是异步的。也就是说,它包含顶层 await。

🌐 When trying to require() an ES Module, the module turns out to be asynchronous. That is, it contains top-level await.

当未捕获时,标志 --experimental-print-required-tla 会将图中顶层 await 的位置打印到标准错误。

🌐 When uncaught, the flag --experimental-print-required-tla prints the locations of the top-level awaits in the graph to stderr.

此错误具有以下其他不可枚举的属性:

🌐 This error has the following additional non-enumerable properties:

  • requireStack <string[]> 导致 require() 失败的模块链,从需要异步模块的那个模块开始。
  • topLevelAwaitLocations <Object[]> 图中顶层 await 的位置。只有在启用 --experimental-print-required-tla 时才会填充。每个条目都有以下属性:
    • url <string> 包含顶层 await 的模块的 URL。
    • line <number> 顶层 await 的从 1 开始的行号。
    • column <number> 顶层 await 的从 1 开始的列号。
    • sourceLine <string> 包含顶层 await 的源代码行。