错误代码门户
Node.jsNode.js错误代码

ERR_REQUIRE_CYCLE_MODULE

require cycle module

代码 ERR_REQUIRE_CYCLE_MODULE · Node.js 报告的问题。

当尝试 require() ES 模块时,CommonJS 到 ESM 或 ESM 到 CommonJS 边缘会参与立即循环。这是不允许的,因为 ES 模块在已经被评估时无法被评估。 为了避免循环,循环中涉及的 require() 调用不应发生在 ES 模块(通过 createRequire())或 CommonJS 模块的顶层,而应在内部函数中延迟完成。

Google Translate · 此内容为自动翻译。技术术语及适用条件请以英文原文为准。

When trying to require() an 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. 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.

故障排除与诊断链接

请先确认文档中的产品、版本及发生环境与当前情况一致。