0

this is my gulpfile.js

const gulp = require('gulp');
gulp.task('default', function () {
});

I write gulp in my terminal and response is..

[19:47:02] Using gulpfile D:\DEV64\LearningJS\gulpfile.js

[19:47:02] Starting 'default'...

[19:47:02] The following tasks did not complete: default

[19:47:02] Did you forget to signal async completion?

what can i do?

Namkun
  • 27
  • 1
  • 6
  • have you tried logging to the console inside the task, just to see if it is being called? `console.log("Something")` – Simon Dec 11 '18 at 12:14

2 Answers2

7

In Gulp 3.x you didn't need to signal completion. But from Gulp 4.x you need to do that.

Gulp automatically passes a callback function to your task as its first argument. Simple way in your case would be calling the callback.

gulp.task('default', function(done) {
  console.log("Started");
  done();
});

For more information You can check this question out: Gulp error: The following tasks did not complete: Did you forget to signal async completion?

Aritra Chakraborty
  • 12,123
  • 3
  • 26
  • 35
4

This works nicely for me.

gulp.task('default', async  function(){
  console.log("This is default task!");
});

You can also try this one.

gulp.task('default', async ()=>
 console.log('This is default task!')
);
Mobarak Ali
  • 751
  • 5
  • 19
  • My Friend, This makes no sense. `Async` function should have an `await` to wait for an asynchronous task. – Imran Rafiq Rather May 26 '21 at 20:35
  • @ImranRafiqRather `await` is used to resolve a promise returned by any function marked as `async`, however it's not the only way to resolve a Promise. Anyway, gulp is already instructed that the function may return a promise and thus handles it appropriately behind scene. So no need for `await` – Sergey Pleshakov Jan 04 '22 at 17:13
  • Where to write this piece of code? – Gowthamss Aug 17 '22 at 11:39