Skip to content

[ERR_REQUIRE_ESM]: require() of ES Module error on keystone build #9478

@quintal-william

Description

@quintal-william

I wanted to update my keystone dependencies because the new version supports React 19. Thanks for the update by the way! 🥳

However, when I ran keystone build, I stumbled apon an error I can't seem to get rid of. I'd love your input if possible. Thanks in advance!

Steps to reproduce

  1. Upgrade @keystone-6/core from 6.3.1 to the first release candidate 0.0.0-rc-20250210004303
  2. Upgrade @keystone-6/fields-document from 9.1.1 to the same release candidate 0.0.0-rc-20250210004303
  3. run pnpm keystone build (in my case: pnpm dotenv -- keystone build)
  4. All steps until "Compiled successfully" behave normally.
  5. Observe error: unhandledRejection Error [ERR_REQUIRE_ESM]: require() of ES Module /@keystar/ui/dist/keystar-ui-table.js from /admin-ui/pages/App/dist/keystone-6-core-___internal-do-not-use-will-break-in-patch-admin-ui-pages-App.cjs.js not supported.

It seems that the cli uses the cjs build of the @keystone/core package, which then attempts to import the esm-only @keystar/ui build.

The error does not occur when adding the --no-ui flag to the build command.

System details

  • Linux mint
  • Pnpm 9.3.0
  • Node v22.11.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions