Skip to content

False positive ERR_REQUIRE_CYCLE_MODULE error thrown for dual package with module-sync entry #57869

@JounQin

Description

@JounQin

Version

v22.14.0

Platform

Darwin JounQin---MacBook-Pro-Max.local 24.4.0 Darwin Kernel Version 24.4.0: Wed Mar 19 21:16:34 PDT 2025; root:xnu-11417.101.15~1/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?

un-ts/pkgr#391

eslint-plugin-jsonc is pure commonjs, eslint-plugin-mdx, synckit and @pkgr/core are all dual package but ESM as primary, so when using eslint.config.js(ESM), eslint-plugin-jsonc loads synckit and @pkgr/core as commonjs, eslint-plugin-mdx loads synckit and @pkgr/core as ESM, which could result this error.

How often does it reproduce? Is there a required condition?

consistent

What is the expected behavior? Why is that the expected behavior?

No error thrown

What do you see instead?

eslint.config.mjs: Error [ERR_REQUIRE_CYCLE_MODULE]: Cannot require() ES Module [REDACTED_ROOT]/node_modules/@pkgr/core/lib/index.js in a cycle. (from [REDACTED_ROOT]/node_modules/eslint-plugin-jsonc/node_modules/synckit/lib/index.cjs)
at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:346:15)
at loadESMFromCJS (node:internal/modules/cjs/loader:1385:24)
at Module._compile (node:internal/modules/cjs/loader:1536:5)
at Object..js (node:internal/modules/cjs/loader:1706:10)
at Module.load (node:internal/modules/cjs/loader:1289:32)
at Function._load (node:internal/modules/cjs/loader:1108:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
at Module.require (node:internal/modules/cjs/loader:1311:12)
at require (node:internal/modules/helpers:136:16)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions