In our ember.js based project after getting latest code and running following commands:

npm install && bower install
npm start

when I was starting app, it was failing randomly with following error.

(FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)

throw er; // Unhandled 'error' event
Error: watch EMFILE
at exports._errnoException (util.js:746:11)
at FSEvent.FSWatcher._handle.onchange (fs.js:1161:26)

npm ERR! Darwin 14.5.0
npm ERR! argv "node" "/usr/local/bin/npm" "start"

To solve this issue I tried doing following
npm cache clean
rm -rf node_modules bower_components dist tmp

Then reinstallation of everything. After that it was still failing randomly.

A lot of developers have faced this issue and many said when we restart the machine it work well. And same happened with me. However I was not happy about this solution at all. Because I cannot start my laptop every time to run the app

So I stumbled upon one of the github issue post and that solution really worked well. As I am using sublime, so I created a file with extension .sublime-project
e.g. goodcity.sublime-project

Added following content in my PROJECTNAME.sublime-project file
"folder_exclude_patterns": [

Then to be on safer side I closed my sublime and reloaded it. Then I cleaned up npm cache using npm cache clean

And started app

npm install && bower install
npm start

Now everything works perfectly!! Even if you want to skip last step that is OK because after adding the sublime-project file content. If we start app directly it will work

Thanks to github issue post.

To learn more about Sublime-project file click here

NOTE: After doing all above mentioned changes if you still randomly face same issue, then I would suggest just close your Sublime app if you are using sublime. Then start the servers and you will see it will start working. To understand more about it you can read this issue