When using various tools on Windows, eg browserify
, I frequently see:
Error: EMFILE: too many open files, open 'C:\Users\mike\Documents\myapp\node_modules\babel-polyfill\node_modules\core-js\package.json'
at Error (native)
Unlike Linux, where maximum open files is a soft limit that chan be changed, it seems EMFILE is a hard limit in Windows.
How can I fix this?
note: I have solved the problem, but it took a week and I couldn't find anything on the internet when I searched, so I'm about to put the answer here for the next node-Windows person
The graceful-fs module can be used to limit the amount of file IO, slowing things down a little but avoiding node crashes due to EMFILE.
// Monkey-patch real fs module, so all I/O uses graceful FS.
var fs = require('fs')
var gracefulFs = require('graceful-fs')
gracefulFs.gracefulify(fs)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With