Skip to content

LTS verison issue #5

@utkarsh232005

Description

@utkarsh232005

Bug: ERR_REQUIRE_ASYNC_MODULE when running kdm on Node.js v24

Description

Running the kdm CLI on Node.js v24 fails with an ESM/CommonJS compatibility error caused by attempting to require() an ESM module (ink) that uses top-level await.

The CLI crashes immediately on startup.


Steps to Reproduce

  1. Install the CLI globally:
npm install -g kdm-cli
  1. Run the CLI:
kdm

Expected Behavior

The CLI should start normally and display the application UI.


Actual Behavior

The CLI exits immediately with the following error:

node:internal/modules/esm/module_job:537
      throw new ERR_REQUIRE_ASYNC_MODULE(filename, parentFilename);
      ^

Error [ERR_REQUIRE_ASYNC_MODULE]: require() cannot be used on an ESM graph with top-level await. Use import() instead.

From:
/home/utkarsh-patrikar/.nvm/versions/node/v24.15.0/lib/node_modules/kdm-cli/dist/index.js

Requiring:
/home/utkarsh-patrikar/.nvm/versions/node/v24.15.0/lib/node_modules/kdm-cli/node_modules/ink/build/index.js

    at ModuleJobSync.runSync (node:internal/modules/esm/module_job:537:13)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:366:47)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1649:24)
    at Module._compile (node:internal/modules/cjs/loader:1812:5)
    at Object..js (node:internal/modules/cjs/loader:1961:10)
    at Module.load (node:internal/modules/cjs/loader:1553:32)
    at Module._load (node:internal/modules/cjs/loader:1355:12)
    at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
    at Module.require (node:internal/modules/cjs/loader:1576:12)
    at require (node:internal/modules/helpers:153:16) {
  code: 'ERR_REQUIRE_ASYNC_MODULE'
}

Node.js v24.15.0

Environment

Component Version
OS Ubuntu Linux
Node.js v24.15.0
Package kdm-cli

Root Cause

kdm-cli is currently compiled or configured as CommonJS while the ink package is ESM-only and internally uses top-level await.

Node.js v24 strictly prevents loading ESM modules with top-level await using require().

The issue originates from:

const { render } = require("ink");

or any CommonJS import path that attempts to load ink.


Suggested Fix

Migrate the CLI to native ESM.

1. Update package.json

{
  "type": "module"
}

2. Update tsconfig.json

{
  "compilerOptions": {
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "target": "ES2022"
  }
}

3. Replace CommonJS imports

Replace:

const { render } = require("ink");

with:

import { render } from "ink";

4. Rebuild the project

npm run build

Temporary Workaround

Downgrade ink to a CommonJS-compatible version:

npm install ink@4

or

npm install ink@3

Additional Notes

This issue appears specifically on newer Node.js versions (v24+) where ESM restrictions are more strictly enforced.

Older Node.js versions may still work due to more permissive ESM/CommonJS interoperability behavior.
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions