0
votes

I have a simple install gulp livereload:

gulp assert.js:42 throw new errors.AssertionError({ ^

AssertionError [ERR_ASSERTION]: Task function must be specified at Gulp.set [as _setTask] (c:\testjses6\node_modules\undertaker\lib\set-task.js:10:3) at Gulp.task (c:\testjses6\node_modules\undertaker\lib\task.js:13:8) at Object. (c:\testjses6\gulpfile.js:21:6) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18)

2
You have to show your gulpfile.js.Mark

2 Answers

4
votes

The problem you are encountering is that you are running gulp v4.0 using gulp 3 syntax. The AssertionError: Task function must be specified error comes from the fact that gulp.task has changed and the 3 parameters signature was removed. In short, tasks that look like the one below will need to be changed to remove the [] parameter:

gulp.task('default', ['build'], function () {
  return runSequence(['watch', 'karma-watch']);
});

This article will help you migrate to gulp 4 syntax.

If you'd like a simple fix to your problem, without having to make changes to your gulpfile.js, run the following command to downgrade your version of gulp from version 4 to 3.9.1:

npm install [email protected] --save

Assuming all goes well you should no longer see the Assertion error.

1
votes

gulp 4 creates many issues with old implementations, modify you tasks declarations:

  • Old syntax:

    gulp.task('a', ['b', 'c'], function () { // do something })
    
  • New syntax:

    gulp.task('a', gulp.series(gulp.parallel('b', 'c'), function () {  // do something }))
    

Hope this helps someone, I figured it after spending hours troubleshooting.