NodeJS – Gulp – AssertionError [ERR_ASSERTION] – Fix
While migrating from Gulp 3.x to Gulp 4.x, these are some AssertionError errors we may getting:
Errors:
- AssertionError [ERR_ASSERTION]: Task function must be specified
- AssertionError [ERR_ASSERTION]: Task never defined:
- The following tasks did not complete: Did you forget to signal async completion?
How to Fix Assertion Error?
Here are few points to take care task definition and execution:
- First define task
- Use return
- Then execute with gulp.series()
Here, is the quick Gulp code which is working with Gulp v4:
// First define task with Return
gulp.task('css-minify', function () {
return gulp.src('assets/images/*.*')
.pipe(smushit({verbose: true}))
.pipe(gulp.dest('assets/images'));
});
// Then execute task with bracket '()' instead of '[]'
gulp.task('default', gulp.series('css-minify'));
Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments |
---|
No Content Found. |
Interview Questions & Answers |
---|
No Content Found. |