javascriptnode.jsgulpgulp-watchgulp-less

Gulp plumber cannot pipe to undefined


I am trying, to write a module that when gulp is watching a task, and a Less file changed with some error, it should give a message to the console, but it should not crash the system, which it does no: This is the code I have written:

var onError = function (err) {  
  console.log(err);
};

gulp.task('styles', function () {  
   gulp.src('./{views}/**/*.{less}')
     .pipe(plumber({
       errorHandler: onError
     }))
     .pipe(less())
     .pipe(gulp.dest('build/styles/common.css'));
 });

When I run the above code, I get the error below:

'styles' errored after 20 ms
Error in plugin 'plumber'
Message:
    Can't pipe to undefined

Solution

  • Yes I have installed gulp-less, and I figured out the solution for this problem aswell: It should be as follow:

      gulp.task('mystyle', function () {  
        gulp.src('build/stylesfiles.less').pipe(plumber()).pipe(less()).
        pipe(gulp.dest ('build/styles/assets'));
        });
    

    Basically I do not need the Error message, it will give me a default error, which can get my job done.Using the above code will make sure it runs, and gives me my error, but not crash the server....but thank you "Apercu"