ERR_REQUIRE_CYCLE_MODULE
稳定性: 1 - 实验性的
¥Stability: 1 - Experimental
尝试 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.