Fixing EMFILE error


If you're on a Mac like me and you develop sizeable Node.js applications you will at some point suffer from the issue which manifests itself in something like this:

EMFILE, too many open files /app/node_modules/random-module/index.js

The problem behind this is the Mac's unusually low open file descriptors limit (256).

To change this simply enter this command in terminal and your issue will be gone:

ulimit -n 1024

Then simply run your app in the same terminal session. You may need to increase the limit even further depending on the size and complexity of your application.

It's also worth checking out this thread on Stack Exchange about persisting ulimit settings.

Tags: node, error, troubleshooting