Skip to content
Discussion options

You must be logged in to vote

Hi @hasezoey

Yes, require(esm) is supported, but there is one additional requirement in Jest: Jest itself still needs to be started with Node's --experimental-vm-modules flag.

Your reproduction currently has:

"scripts": {
  "test": "jest"
}

Change that to:

"scripts": {
  "test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js"
}

or run Jest with:

NODE_OPTIONS=--experimental-vm-modules npm test

The reason plain Node works while Jest does not is that Jest executes ESM through Node's vm.Module APIs. Even on Node 26, those APIs are still gated behind --experimental-vm-modules.

So Node 24.9+ is required for Jest's synchronous require(esm) implementation, but it does not remove …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@hasezoey
Comment options

@portyu9
Comment options

@hasezoey
Comment options

@portyu9
Comment options

Answer selected by hasezoey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants