Skip to content

Build fails on node 20.18.2 due to require() of ES Module pkg-types since 7.10.0 release #14622

@andreiborza

Description

@andreiborza

Reproduction

Requires: Volta or manually running this with node 20.18.2

  1. Clone https://github.com/andreiborza/ab-rr-node-20-18-2
  2. run pnpm install
  3. run pnpm build

System Info

System:
    OS: macOS 15.5
    CPU: (12) arm64 Apple M3 Pro
    Memory: 1.33 GB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.18.2 - <redcated>/.volta/tools/image/node/20.18.2/bin/node
    Yarn: 1.22.22 - <redcated>/.volta/tools/image/yarn/1.22.22/bin/yarn
    npm: 10.8.2 - <redcated>/.volta/tools/image/node/20.18.2/bin/npm
    pnpm: 9.15.9 - <redcated>/.volta/bin/pnpm
    bun: 1.3.1 - <redcated>/.bun/bin/bun
    Deno: 2.1.6 - <redcated>/.deno/bin/deno
    Watchman: 2024.12.02.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 143.0.7499.41
    Firefox: 145.0.2
    Safari: 18.5
  npmPackages:
    @react-router/dev: ^7.9.2 => 7.10.0
    @react-router/node: ^7.9.2 => 7.10.0
    @react-router/serve: ^7.9.2 => 7.10.0
    react-router: ^7.9.2 => 7.10.0
    vite: ^7.1.7 => 7.2.6

Used Package Manager

pnpm

Expected Behavior

Project builds correctly.

Actual Behavior

> my-react-router-app@ build <redacted>/ab-rr-node-20-18-2
> react-router build

node:internal/modules/cjs/loader:1309
    throw new ERR_REQUIRE_ESM(filename, true);
    ^

Error [ERR_REQUIRE_ESM]: require() of ES Module <redacted>/ab-rr-node-20-18-2/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs not supported.
Instead change the require of <redacted>/ab-rr-node-20-18-2/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs to a dynamic import() which is available in all CommonJS modules.
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at Object.<anonymous> (<redacted>/ab-rr-node-20-18-2/node_modules/.pnpm/@react-router+dev@7.10.0_@react-router+serve@7.10.0_react-router@7.10.0_react-dom@19.2.0_reac_dd6zxms4crew7mlwvsm2nood3y/node_modules/@react-router/dev/dist/cli/index.js:2158:25) {
  code: 'ERR_REQUIRE_ESM'
}

Seems related to https://app.unpkg.com/@react-router/dev@7.10.0/files/dist/cli/index.js#L742 not being wrapped with _toESM in the build output.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions