'events.js:174 Error: write EPIPE at ChildProcess.target._send when running jest

node -v v10.19.0

.\node_modules.bin\jest -v 26.0.1

CPU is intel Xeon 16 cores/32 threads and 32GB memeory

when I run jest --coverage, I always got failure like

events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at ChildProcess.target._send (internal/child_process.js:762:20)
    at ChildProcess.target.send (internal/child_process.js:634:19)
    at ChildProcessWorker.send (C:\src\mytest\node_modules\jest-worker\build\workers\ChildProcessWorker.js:291:17)
    at WorkerPool.send (C:\src\mytest\node_modules\jest-worker\build\WorkerPool.js:32:34)
    at Farm._process (C:\src\mytest\node_modules\jest-worker\build\Farm.js:129:10)
    at Farm._enqueue (C:\src\mytest\node_modules\jest-worker\build\Farm.js:152:10)
    at Farm._push (C:\src\mytest\node_modules\jest-worker\build\Farm.js:159:12)
    at Promise (C:\src\mytest\node_modules\jest-worker\build\Farm.js:90:14)
    at new Promise (<anonymous>)
    at Farm.doWork (C:\src\mytest\node_modules\jest-worker\build\Farm.js:56:12)
Emitted 'error' event at:
    at process.nextTick (internal/child_process.js:766:39)
    at process._tickCallback (internal/process/next_tick.js:61:11)

I have tried run the command line window with administrator privilege. add parameters such as --maxWorkers=4 or set NODE_OPTIONS= --max-old-space-size=4096

all failed with the same erors.

If I used the parameter --runInBand, I will get

events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, open ''
Emitted 'error' event at:
    at lazyFs.open (internal/fs/streams.js:115:12)
    at FSReqWrap.args [as oncomplete] (fs.js:140:20)

Any help will be much appreciated.



Solution 1:[1]

This is likely an issue of running out of memory. You might have a memory leak, which apparently jest's design makes pretty easy to do. That link also describes how to investigate memory leaks.

Solution 2:[2]

I had the same problem. I tried rebooting. It helped.

Try rebooting :-)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Billy Tetrud
Solution 2 YotKay