Gulp error: gulp.hasTask is not a function

Gulp v4 has breaking changes and that creates some problems with run-sequence package.

As I do not have your gulpfile.js, all I can say upto this point is to try to use Gulp4's gulp.series and gulp.parallel with your gulp tasks, instead of run-sequence.

you may receive an error of the sort of like 'task1, 'task2' could not be completed', in the function of the task, accept the done callback and call the callback in your tasks at the end of the function

Example:

gulp.task('task1', gulp.series('task1-1', function (done) {
   // task 1 code here
    done();
}));

gulp.task('task2', gulp.series('task2-1', function (done) {
   // task 2 code here
    done();
}));

// Similarly Tasks 3 and 4 Code here

gulp.task('main', gulp.series('task1', 'task2', 'task3', 'task4', function (done) {
    done();
}));

All that matters is the Local Version. Since gulp 4.0.0 introduced breaking changes, you can simply do what I did --- explicitly set the local package back to a working version:

npm install --save-dev [email protected]

This has bit me a couple times recently and I'll be coming back here again, I'm sure.

Note: The dependencies of gulp 3.9.1 have many security vulnerabilities. You should not do this.


Saurabh Pati's answer is the answer. BTW a quick workaround would be to replace run-sqeuence package with the gulp4-run-sequence package.

If your project has Gulp installed locally, remove local version of Gulp:

yarn remove gulp

Then open the package.json and replace "run-sequence": "^0.3.6", with

"gulp4-run-sequence": "^1.0.0",

Now run

yarn install

In your Gulpfile.js, replace runSequence = require('run-sequence'), with

runSequence = require('gulp4-run-sequence'),

And, you are done. :)