N
N
Nikolay Matyushkin2018-12-21 14:36:35
gulp.js
Nikolay Matyushkin, 2018-12-21 14:36:35

gulp.watch doesn't work. What's wrong?

Started learning gulp. I ran into a problem when running the watch task to track changes to style files.

var gulp = require('gulp'),
  sass = require('gulp-sass');

gulp.task('sass', function() {
  return gulp.src('app/sass/main.sass')
  .pipe(sass())
  .pipe(gulp.dest('app/css'))
});

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

I run the task, I get an error: Error: watching app/sass/main.sass: watch task has to be a function (optionally generated by using gulp.parallel or gulp.series)
Please help me figure it out.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
coderxx, 2018-12-21
@Devilz_1

The error is that you probably have Gulp version 4 installed using the gulp.parallel function, while this gulpfile configuration is for Gulp version 3. The easiest way is to rollback Gulp version to 3.9.1, or fix gulpfile. js:

gulp.task("watch", function() {
  gulp.watch('app/sass/main.sass', gulp.parallel('sass'));
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question