Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Gulp Basics Welcome to Gulp.js Your First Gulp Task

I'm done with this course!!! Everything just turned into a mess

I believe that the concept in this course should be more clear. I'm a beginner and after a while in this course I don't know what I'm doing. Every command line in terminal turn into an error....

'use strict';

var gulp = require('gulp');
var gulp_cli = require('gulp-cli');

gulp.task('hello', function() {
    console.log('Hello!');
});

gulp.task('default', ['hello'], function() {
    console.log('This is the dafault task!');
});
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: Task function must be specified
    at Gulp.set [as _setTask] (/Users/sharifi/Downloads/s1/node_modules/undertaker/lib/set-task.js:10:3)
    at Gulp.task (/Users/sharifi/Downloads/s1/node_modules/undertaker/lib/task.js:13:8)
    at Object.<anonymous> (/Users/sharifi/Downloads/s1/gulpfile.js:10: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)

Hey everyone, its ok to be frustrated, but some basic googling and looking at the gulp documentation revealed the answer.

In version 4, gulp changed from just accepting an array of strings that trigger other tasks to requiring a call to either the gulp.parallel() or gulp.series() methods. These methods added the ability to define whether tasks must be run one after another, or run simultaneously. If you change this:

gulp.task('default', ['hello'], function() {
    console.log('This is the dafault task!');
});

To this:

gulp.task('default', gulp.parallel('hello', function(done){
    console.log('This is the dafault task!');
    done();
}));

Then you will get the result shown in the video. The added done() method stops a warning from being thrown in the terminal, but isn't necessary for the task to complete its purpose.

One of your most valuable skills is perseverance. When you get an error, do a bit of googling, check the forums and ask for help. Frustration only hurts yourself.

2 Answers

Tsenko Aleksiev
Tsenko Aleksiev
3,819 Points

It’s your choice but keep this in mind: no one can open your head and just fill in all you want to know. I’m still waiting for somebody to come up with a way to plug in a usb cable to my head and upload all I want ( ahhh the matrix ). If you quit so quick and give up, you will never learn to code. No matter which course you use, you have to dig in google, read other peoples code, try to figure out things for yourself. If you don’t understand something whatch the video again, rewrite your code from top to bottom. I had so many times the pleasure to start over and over again, keep watching my code for more than a week, and in the end the reason is just a typo...yes it’s frustraiting but tell me can you start learning japanese and start speaking and writing in a day or a week? How about gym - can you lift 200 kg within your first week? It needs time and efford...a lot. And btw I’m a noob as well :)

The course hasn't been updated in 3 years (last commit on Git). So basically I can tell you I understand his frustration. Also, Gulp has dependency issues. They need to update this course and most of their courses for these particular issues. People whom don't have experience with these things could use the help...

Mark Warren
Mark Warren
19,250 Points

I ran into this error too, and I think it had something to do with pulling it directly from the github repo that hadn't been updated in YEARS. What I had to do was download the files directly from the course where I was stuck, then reinstall gulp and the gulp modules again, in your case gulp and gulp-cli.