Error: EMFILE, too many open files with Gulp.watch

My gulpfile.js looks like this:

gulp.task('default', ['build', 'browser-sync'], function () {
    gulp.watch("**/*.css", ['bs-reload']);
    gulp.watch(["**/*.js", "!**/*/node_modules/**/*.*"], ['bs-reload']);
    gulp.watch("**/*.html", ['bs-reload']);
});

      

Even if I exclude node_modules it tries to add clocks to all node_modules.

How can this be ruled out?

Note that node_modules does not exist in the project root, infecting it above the project root, so why does it even bother including the same one?

Error: EMFILE, too many open files '/Users/**/Documents/gits/tm/node_modules/browser-sync/lib/public/socket.io.js'
    at Object.fs.openSync (fs.js:438:18)
    at Object.fs.readFileSync (fs.js:289:15)
    at Object.utils.getSocketScript (/Users/**/Documents/gits/tm/node_modules/browser-sync/lib/snippet.js:109:19)

      

+3


source to share


1 answer


Try this as a tighter replacement for fs

:

graceful-fs



Global patch fs

:

var realFs = require('fs')
var gracefulFs = require('graceful-fs')
gracefulFs.gracefulify(realFs)

      

+4


source







All Articles