I am using Node.js (0.10.31) and Gulp (3.8.8) for 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.
I want to know whether there is any limitation that prevent opening more files/sockets in Windows 7 that causes EMFILE error
or not?
If yes, how can I change that limitation?
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.