0

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 I am getting errors. The project contains 5 files:

  1. index.html
  2. package.json
  3. styles.css
  4. styles.less
  5. gulpfile.js

I'm only using two modules:

  1. gulp
  2. gulp-less

So far so good. Here are the contents of gulpfile.js:

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(''));
});

I would expect running gulp in the terminal would start the watching process. Instead, it's producing the following error (I'm copying line-for-line what I see in the terminal):

[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've been seeing this error in other projects, so to make sure I wasn't crazy, I whipped up the simplest use-case I could think of. For the record, here are the versions of everything I'm running:

  • npm: 3.5.3
  • node: 5.4.1
  • gulp:
    • CLI version: 3.9.0
    • Local version: 3.9.0
  • gulp-less: 3.0.5

UPDATE: I've created an issue over at the official gulp repo on github. Trying whatever I can to solve this.

UPDATE 2: I use Sublime text editor. Having too many windows open (i.e. too many files open) will trigger this issue. When I close some of those windows, this issue goes away. I still can't find a consistent "this many windows / files open" scenario, so from my viewpoint it's still somewhat of a mystery.

The Qodesmith
  • 3,205
  • 4
  • 32
  • 45

1 Answers1

0

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 the will help you