yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒
https://yarnpkg.com
BSD 2-Clause "Simplified" License
7.23k stars 1.07k forks source link

[Bug?]: `ERR_REQUIRE_ESM` in Yarn PnP mode using Node.js 22 with `--experimental-require-module` flag #6336

Open NMinhNguyen opened 2 weeks ago

NMinhNguyen commented 2 weeks ago

Self-service

Describe the bug

ERR_REQUIRE_ESM when requiring an ES module from CommonJS using Yarn PnP with Node.js 22 with --experimental-require-module flag.

To reproduce

https://codesandbox.io/p/devbox/nervous-leavitt-ndnn53

yarn start

Environment

System:
  OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
  CPU: (2) X64 AMD EPYC
Binaries:
  Node: 22.3.0 - / tmp/xfs-d3661e12/node
  Yarn: 4.3.0 - /tmp/xfs-d3661e12/yarn
  npm: 10.8.1 - /usr/local/share/nvm/versions/node/v22.3.0/bin/npm
  pnpm: 8.15.6 - /usr/local/share/npm-global/bin/pnpm

Additional context

Would expect this to work, thanks to https://github.com/nodejs/node/pull/51977.

Disabling Yarn PnP works: https://codesandbox.io/p/devbox/nervous-leavitt-forked-9mgdvt