I am using Node.js (0.10.31) and Gulp (3.8.8) to automating some tasks in Windows 7 but I've faced following error:
events.js:72
throw er; // Unhandled 'error' event
^
Error: EMFILE, open 'c:\myproject\package.json'
I have moved the project to Ubuntu and fix that using ulimit -n
command but still curious about how to solve that in Windows.
Now, first I want to know whether there is any limitation that prevent opening more files/sockets in Windows 7 that cause EMFILE error
or not?
Secondly, if yes, how can I change that limitation?
EMFILE means error maximum files which indicates that the OS is denying your program to open more file descriptors.27-Apr-2012.
emFile is a fail-safe file system for embedded systems and applications which can be used on any storage device. It is a high-performance library optimized for minimum memory consumption in RAM, ROM, high speed, and versatility working on any embedded device.
There is a limitation inside the VSC++ runtime. An application can only open 512 file descriptors through the runtime, although the value can be increased to 2048 if the application calls _setmaxstdio
(which I think node doesn't). (This is a somewhat simplified explanation, for more details see here.) You can't change this limitation directly (you could only raise the 512 to 2048 if you would get node to call this function for you somehow).
However you wrote you are using node v0.10.31 which is pretty old. As far as I know (although I'm not 100% certain about that), node had in the meantime switched from using the VSC++ runtime for File I/O to native WinAPI calls which do not have this limitation, so you could try the latest node version if that's an option for you.
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