Search code examples
gulpgulp-watchwindows-subsystem-for-linux

Gulp watch EPERM on Windows


Using gulp and the new Microsoft bash shell, I am trying to set up a gulp watch to compile my scss into css, in a way that the watch doesn't stop when there is an error compiling it.

I've set up a gulp task called sass to do this, and I can run it fine from the command line with gulp sass, but when I try to run my gulp watch command with gulp watch I get an EPERM error which I've been unable to fix in a way to get my gulp.watch working. Here is the error messages output to the command line, below.

bash shell error messages

I've tried changing permissions on my node_modules folder, as well using sudo to do, but I still get this error. Help would be greatly appreciated.

var gulp = require('gulp');
var sass = require('gulp-sass');
var plumber = require('gulp-plumber');
var notify = require('gulp-notify');

gulp.task('watch', ['sass'], function() { 
    gulp.watch('app/scss/**/*.scss', ['sass']);
})

gulp.task('sass', function() {
  return gulp.src('app/scss/**/*.scss')
    .pipe(customPlumber('Error Running Sass'))
    .pipe(sass())
    .pipe(gulp.dest('app/css'))
})

function customPlumber(errTitle){
    return  plumber({
        //use notify plugin to report error as windows toaster message
        errorHandler:notify.onError({
                //Customizing error title
                title:errTitle || "Error running Gulp",
                message: "Error: <%= error.message %>",
        })
    });
}

Solution

  • WSL doesn't support FS notify syscalls in Slow/Preview/Production rings. In the Fast ring, it supports tracking changes made inside WSL. Devs promise support for tracking changes made in Windows will be added soon enough.

    Related links: