Skip to content

Instantly share code, notes, and snippets.

@anthonyray
Last active August 29, 2015 14:25
Show Gist options
  • Save anthonyray/4f1d6845af7d35608de9 to your computer and use it in GitHub Desktop.
Save anthonyray/4f1d6845af7d35608de9 to your computer and use it in GitHub Desktop.
EM file error when using browserify and react.

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment