-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Description
Version
29.7.0
Steps to reproduce
Have a Jest unit test use require() on a dependency with an "exports" field giving ESM
Expected behavior
When running Node.js 20.19, require(esm) should work.
https://nodejs.org/en/blog/release/v20.19.0
Actual behavior
jest/packages/jest-runtime/src/index.ts
Lines 960 to 969 in ac334c0
| if (this.unstable_shouldLoadAsEsm(modulePath)) { | |
| // Node includes more info in the message | |
| const error: NodeJS.ErrnoException = new Error( | |
| `Must use import to load ES Module: ${modulePath}`, | |
| ); | |
| error.code = 'ERR_REQUIRE_ESM'; | |
| throw error; | |
| } |
Additional context
It'd be great to get a patch release of 29.7.1 that uses the more relaxed behavior of node 20.x. Node.js 18 has been EOL since April 30.
Environment
All of themXunnamius, shrujalshah28, TheHolyWaffle, alexis-letexier and gaetanmaisse