Search code examples
javascriptnode.jsgulpgulp-watchgulp-livereload

I'm getting error in node using gulp and gulp-livereload


i downloaded livereload extension but it's not working, here's the error.

Error: watching ./src/*.css: watch task has to be a function (optionally generated by using gulp.parallel or gulp.series)

var
    gulp = require("gulp"),
    livereload = require("gulp-livereload");

gulp.task("reload-css", function() {
    gulp.src('./src/*.css')
        .pipe(livereload());
});

gulp.task("default", function() {
    livereload.listen();
    gulp.watch('./src/*.css', ['reload-css']);
});

So what should i do now ?


Solution

  • it looks like you're using gulp 4, but write gulp 3 syntax. Try

    gulp.watch('./src/*.css', gulp.series('reload-css'))
    

    Check out the gulp 4 docs. This post highlight the differences in the new gulp.