I am using gulp and browserify to structure my javascript application built with reactjs. One day, when I was bundling my javascript files into a single one, I stumbled upon this error :
➜ front git:(frontend) ✗ gulp browserify
[11:02:49] Using gulpfile ~/xxx/xxx/xxx/xxx/front/gulpfile.js
[11:02:49] Starting 'browserify'...
events.js:72
throw er; // Unhandled 'error' event
^
Error: EMFILE, open '/Users/xxx/xxx/xxx/node_modules/react/package.json'
After having looked on the web, I found that this error was due to the fact that a single process have a limited number of file handles it can have simultaneously opened.
I solve the problem by using the graceful-fs
module. Just npm install graceful-fs
, and add the following lines at the beginning of the gulp file.
var realFs = require('fs')
var gracefulFs = require('graceful-fs')
gracefulFs.gracefulify(realFs)