B
B
Bogdan2019-08-27 19:33:23
JavaScript
Bogdan, 2019-08-27 19:33:23

Gulp 4 gives "The following tasks did not complete... Did you forget to signal async completion". How to fix it?

Hi all !
gulpfile.js:

const gulp = require('gulp'),
      gp = require('gulp-load-plugins')(); 


gulp.task('img:compress', gulp.series( function(cb)  {
  return gulp.src('img/*')
    .pipe(gp.tinypng('RJnL6Rx3l41Y58OJziMBRUeoteR09LBb'))
    .pipe(gulp.dest('compressed_img/'))
 	cb(); 
}));

In the console gives:
[19:11:08] The following tasks did not complete: img:compress, <anonymous>
[19:11:08] Did you forget to signal async completion?

What could be the reason?
How can I change the code so that this message does not pop up in the console anymore?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Flying, 2019-08-27
@Flying

You have a call cb()after returni.e. it is not called at all. But since it is in the list of arguments, gulp is waiting for its call and, without waiting, swears.
In your case, cbit is not needed at all, just remove it from the list of arguments and everything will start working.

R
runprogr, 2019-08-27
@runprogr

gulp.task('img:compress', function  {
  return gulp.src('img/*')
    .pipe(gp.tinypng('RJnL6Rx3l41Y58OJziMBRUeoteR09LBb'))
    .pipe(gulp.dest('compressed_img/');
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question