Skip to content

commandkit/events throws SyntaxError (export in .cjs) and commandkit/cli points to a missing cli.cjs #643

Open

Description

@trackoor

Two exported subpaths in commandkit fail to load at runtime in both ESM and CommonJS: commandkit/events throws SyntaxError: Unexpected token 'export', and commandkit/cli fails with ERR_MODULE_NOT_FOUND / MODULE_NOT_FOUND because cli.cjs is missing from the package.

// repro.mjs
for (const specifier of ['commandkit/events', 'commandkit/cli']) {
  try {
    await import(specifier);
  } catch (err) {
    console.log(`${specifier} -> ${err.name}: ${err.message.split('\n')[0]}`);
  }
}

Run with:

npm init -y
npm pkg set type=module
npm install commandkit@1.2.6 discord.js@14.25.1
node repro.mjs

Actual output:

(node:3517984) Warning: Failed to load the ES module: /path/to/repro/node_modules/commandkit/events.cjs. Make sure to set "type": "module" in the nearest package.json file or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
commandkit/events -> SyntaxError: Unexpected token 'export'
commandkit/cli -> Error: Cannot find module '/path/to/repro/node_modules/commandkit/cli.cjs' imported from /path/to/repro/repro.mjs

require('commandkit/events') and require('commandkit/cli') fail the same way because exports["./events"] and exports["./cli"] map both import and require to ./events.cjs and ./cli.cjs. Both events.d.ts and cli.d.ts are published, so TypeScript compilation succeeds and the failure only appears at runtime.

Expected: commandkit/events exports { useEvents }, and commandkit/cli exports { development, production, env, cli, compiler, appProcess, typeChecker, utilities } as documented in apps/website/docs/guide/08-advanced/05-using-cli-api.mdx.

In packages/commandkit/events.cjs, require('./dist/context/async-context.js') is paired with export function useEvents() instead of module.exports = { useEvents }, and packages/commandkit/package.json lists ./cli.cjs in exports["./cli"] and files while the wrapper in the repository is named packages/commandkit/cli.js (so cli.cjs is neither resolved on main nor included in the published tarball).

Tested on commandkit@1.2.6 (npm latest, with discord.js@14.25.1) and main (e65f243) with Node.js v26.13.0.

Credit: https://ucsbplse.github.io/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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