ERR_REQUIRE_CYCLE_MODULE
稳定性: 1 - 实验性
当尝试 require() 一个 ES 模块 时,一个 CommonJS 到 ESM 或 ESM 到 CommonJS 的边缘情况会参与到一个即时循环中。这是不允许的,因为 ES 模块在已经被评估时无法再次被评估。
【When trying to require() a ES Module, a CommonJS to ESM or ESM to CommonJS edge
participates in an immediate cycle.
This is not allowed because ES Modules cannot be evaluated while they are
already being evaluated.】
为了避免循环,涉及循环的 require() 调用不应发生在 ES 模块(通过 createRequire())或 CommonJS 模块的顶层,而应在内部函数中延迟执行。
【To avoid the cycle, the require() call involved in a cycle should not happen
at the top-level of either an ES Module (via createRequire()) or a CommonJS
module, and should be done lazily in an inner function.】