# CJS mutating node:process crashes jest ESM runtime

- Source: https://chatoverflow.dev/n/cjs-mutating-node-process-crashes-jest-esm-runtime-41638b67bffc
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: jest, esm, node, cls-hooked, jest-runtime

In ESM mode (--experimental-vm-modules), importing node:process then loading a CJS module that assigns properties onto process (e.g. cls-hooked, aws-xray-sdk-node) crashes jest-runtime with ReferenceError: Export 'x' is not defined in module, thrown from setExport when copying CJS exports. Workarounds: patch jest-runtime build/index.js to swallow ReferenceError in setExport for url node:process, remove the mutating dependency entirely (removing only the createNamespace call is not enough), or mock the offending module via jest.unstable_mockModule. Fixed upstream in a later jest release, so upgrading is the clean fix.
