question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gulp.watch - Error: watch null EMFILE

See original GitHub issue

gulp.watch is giving an error in the simplest use-case that I’ve set up. I’ve been using gulp.watch in a few projects and this error is “all-of-a-sudden”. Perhaps I’m overlooking something? Are my glasses on my face but I can’t find them?

Here is my gulpfile.js contents:

var gulp = require('gulp');
var less = require('gulp-less');

gulp.task('default', function() {
  gulp.watch('styles.less', ['styles']);
});

gulp.task('styles', function() {
  return gulp.src('styles.less')
  .pipe(less())
  .pipe(gulp.dest(''));
});

As you can see, this is a simple scenario where watching a less file change will result in compiling that file to css. Here’s what I see in the console when I run ‘gulp’:

[19:19:30] Using gulpfile ~/Projects/Sandbox/fred/gulpfile.js
[19:19:30] Starting 'default'...
2016-01-23 19:19 gulp[41595] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
[19:19:30] Finished 'default' after 7.91 ms
events.js:141
  throw er; // Unhandled 'error' event
  ^

Error: watch null EMFILE
  at exports._errnoException (util.js:856:11)
  at FSEvent.FSWatcher._handle.onchange (fs.js:1296:21)

I also tried replacing the contents of the ‘styles’ task to just contain a console.log statement. Same results. Any thoughts on this?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
lichenbulirencommented, Nov 1, 2016

I have the same problem with you . finally i found that the actually problem is that if you open you project directory with command sublime . under terminal,and then run the gulp, that the gulp will cause the error.

so, you can open sublime application first, and then load you project directory, and finally start gulp in the terminal. everything will be ok!

hope this will help you

3reactions
qodesmithcommented, Jan 25, 2016

I only have Sublime, the terminal, and Chrome open at the same time (nothing novel here). What I did notice is that if I close sublime and then run gulp, the process runs with no error. So damn weird. And to add to the weirdness, this error is not consistent. My life.

Read more comments on GitHub >

github_iconTop Results From Across the Web

gulp.watch - Error: watch null EMFILE - Stack Overflow
I've been getting various errors with gulp.watch lately, so I set up a very simple test project. I am clueless as to why...
Read more >
watch() - gulp.js
name type default ignoreInitial boolean true delay number 200 queue boolean true
Read more >
rollup.js
watch function that rebuilds your bundle when it detects that the individual modules have changed on disk. It is used internally when you...
Read more >
How to Fix "throw er; // Unhandled 'error' event"?
npm run watch fails with a rather cryptic "throw er; // Unhandled 'error' event". Here is how I resolved it.
Read more >
gulp-watch - npm
});. Protip: until gulpjs 4.0 is released, you can use gulp-plumber to prevent stops on errors.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found