Skip to content

0.12.0 cli throws Error [ERR_REQUIRE_ESM] on yargs #61

@sch0057k

Description

@sch0057k

Hey,

I tried to update from 0.11.0 to 0.12.0 recently.

I am using the cli but it seems there is some incompatibility with yargs.

According to the package.json the module depends on "yargs": "^18.0.0". I have yargs 18.0.0 installed.

It looks like yargs 18.0.0 is ESM (using .mjs) but its being loaded via const yargs_1 = __importDefault(require("yargs/yargs")); on the cdk-dia cli.js

Error [ERR_REQUIRE_ESM]: require() of ES Module /myproject/node_modules/yargs/index.mjs not supported.
Instead change the require of /myproject/node_modules/yargs/index.mjs to a dynamic import() which is available in all CommonJS modules.
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at Object.<anonymous> (/myproject/node_modules/cdk-dia/dist/bin/cli.js:41:33) {
  code: 'ERR_REQUIRE_ESM'
}

Looks like yargs 18.0.0 is EMS first:

https://classic.yarnpkg.com/en/package/yargs

18.0.0 (2025-05-26)
⚠ BREAKING CHANGES
[...]
yargs is now ESM first

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions