Skip to content

Error [ERR_REQUIRE_ESM]: require() of ES Module zeptomatch — reproduces on Node 20/22/24 and Bun, not fixed by generator config #30263

Description

@joaspiosantos

Bug description

prisma generate (and prisma -v) crashes with ERR_REQUIRE_ESM on Prisma 7.10.0. The crash happens in @prisma/dev's state.cjs, which does a top-level require("zeptomatch") — an ESM-only package ("type": "module", no CJS exports condition). This reproduces regardless of Node version or generator block configuration, so it does not match the "only occurs on Node < 22" explanation given in #28784 / fixed by #28807.

Reproduction

node_modules/prisma/build/index.js generate

Crashes identically whether invoked via bun add -d prisma@7.10.0 (which runs the postinstall: prisma generate script), via bunx prisma generate, or via direct node node_modules/prisma/build/index.js generate — ruling out a Bun-specific invocation issue.

Tried and confirmed not to fix it:

  • Upgrading Node.js to 22.18.0 and to 24.21.0 (via fnm), both freshly installed — identical crash. This directly contradicts the maintainer comment on Error [ERR_REQUIRE_ESM]: require() of ES Module #28784 that this "only occurs when using an out of date and below system requirements version of Node.js".
  • Pinning zeptomatch via overrides/resolutions in package.json to every published version (1.0.0 → 2.1.0, the latest) — every version is ESM-only, so there is no CJS-compatible version to pin.
  • Switching the generator client block from prisma-client-js to the new prisma-client generator, in every combination of its options:
    generator client {
      provider               = "prisma-client"
      output                 = "../src/generated/prisma"
      engineType             = "client"
      runtime                = "bun"
      moduleFormat           = "esm"
      generatedFileExtension = "ts"
      importFileExtension    = "ts"
    }
    The crash happens during the CLI's own bootstrap (loading @prisma/dev) before the schema/generator block is even parsed, so no generator configuration can avoid it.

Expected vs. Actual Behavior

Expected: prisma generate runs successfully with prisma@7.10.0 on Node 20/22/24 and under Bun.

Actual:

Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/zeptomatch/dist/index.js from /path/to/node_modules/@prisma/dev/dist/state.cjs not supported.
Instead change the require of index.js in /path/to/node_modules/@prisma/dev/dist/state.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/path/to/node_modules/@prisma/dev/dist/state.cjs:1:2235) {
  code: 'ERR_REQUIRE_ESM'
}

Environment

  • prisma: 7.10.0
  • OS: Ubuntu 24.04.4 LTS on WSL2 (6.6.87.2-microsoft-standard-WSL2)
  • Runtimes tested, all reproduce identically:
    • Bun 1.4.2 (bundled Node 20.19.6)
    • Node 22.18.0 (via fnm)
    • Node 24.21.0 (via fnm)
  • Package manager: Bun (bun.lock)

Related

Happy to provide a minimal reproduction repo if useful.

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