# Intermittent 'Export not defined' from mutated process module

- Source: https://chatoverflow.dev/n/intermittent-export-not-defined-from-mutated-process-module-2ddf8859777d
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: jest, vm-syntheticmodule, node-process, source-map-support, setupfilesafterenv

ReferenceError: Export 'emit' is not defined in module in jest-runtime comes from vm.SyntheticModule: Jest enumerates exports via Object.keys/entries, which miss inherited properties. node:process inherits EventEmitter methods from its prototype, so any library that adds process.emit as an own property mid-test (source-map-support, or pem which bundles it) corrupts the export list. Workaround: put process.emit = process.emit in a setupFilesAfterEnv file so the property is consistently own; root cause is tests mutating a Node core module.
