Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp: error in console, assert.js:90 throw new assert.AssertionError

I get such an error in console: $ gulp

assert.js:90
  throw new assert.AssertionError({
  ^
AssertionError: Task function must be specified

at Gulp.set [as _setTask] (C:\Users\user\Projects\New project\node_modules\undertaker\lib\set-task.js:10:3)

at Gulp.task (C:\Users\user\Projects\New project\node_modules\undertaker\lib\task.js:13:8)

at Object.<anonymous> (C:\Users\user\Projects\New project\gulpfile.js:44:6)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)

Here is my gulpfile:

var gulp = require('gulp');
var build = require('gulp-build');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var browser_sync = require('browser-sync');
var gulps = require("gulp-series");


//gulp-build
gulp.task('build', function() {
    gulp.src('scripts/*.js')
        .pipe(build({
            GA_ID: '123456'
        }))
        .pipe(gulp.dest('dist'))
});

//gulp-sass
gulp.task('sass', function() {
    return gulp.src('scss/**/*.scss')
        .pipe(sourcemaps.init())
        .pipe(sass({
            errLogToConsole: true,
            outputStyle: 'expanded'
        }).on('error', sass.logError))
        .pipe(sourcemaps.write('./maps'))
        .pipe(gulp.dest('css'));
});

//gulp-browser-sync
gulp.task('browser_sync', function() {
    var files = [
        '*.html',
        'css/*.css'
    ];
    browser_sync.init(files, {
        server: {
            baseDir: './'
        }
    });
});

//gulp-watch
gulp.task('watch', ['sass'], function() {
    gulp.watch('scss/**/*.scss', ['sass']);
});

//gulp-series
gulps.registerTasks({
    "test1": (function(done) {
        setTimeout(function() {
            console.log("test1 is done");
            done();
        }, 1000);
    }),
    "test2": (function() {
        console.log("test2 is done");
    })
});

gulps.registerSeries("default", ["test1", "test2"]);

// gulp.task('default', ['watch', 'browser_sync'], function() {});

I'm just a beginner, have you any idea what I've done wrong?

like image 300
Lebiediev Avatar asked Jul 04 '16 10:07

Lebiediev


1 Answers

I think you use gulp 4 with the gulp 3 'syntax'.
So either install gulp 3 and your gulpfile should be valid and ready to go or migrate it to gulp 4. Here is a good article about that.

Changelog of gulp

like image 58
DAXaholic Avatar answered Sep 18 '22 15:09

DAXaholic