Gulp Error : watch task has to be a function

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

 

If you have ever come across this error this is due to a gulp version issue,

in gulp 3.x versions we used gulp.watch as follow.

gulp.watch('src/**/*.js', ['js']);

But in gulp 4.x you need to pass the task name in a function as follow.

gulp.watch('app/**/*.js', gulp.series('js'));

You can read further about gulp.series here.

Tags