T
T
Taron4uk2019-02-05 22:42:23
gulp.js
Taron4uk, 2019-02-05 22:42:23

Error when starting GULP, how to solve?

Good afternoon. Tell me, please, I copied this code from the documentation of the site https://www.browsersync.io SASS + CSS Injecting:

var gulp        = require('gulp');
var browserSync = require('browser-sync').create();
var sass        = require('gulp-sass');

// Static Server + watching scss/html files
gulp.task('serve', ['sass'], function() {

    browserSync.init({
        server: "./app"
    });

    gulp.watch("app/scss/*.scss", ['sass']);
    gulp.watch("app/*.html").on('change', browserSync.reload);
});

// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
    return gulp.src("app/scss/*.scss")
        .pipe(sass())
        .pipe(gulp.dest("app/css"))
        .pipe(browserSync.stream());
});

gulp.task('default', ['serve']);

Of course, I registered all the folders, under my own, but when launched through the command line, an error occurs
PS C:\Users\Home\Desktop\project> gulp

assert.js:350
    throw err;
    ^

AssertionError [ERR_ASSERTION]: Task function must be specified
    at Gulp.set [as _setTask] (C:\Users\Home\Desktop\project\node_modules\undertaker\lib\set-task.js:10:3)
    at Gulp.task (C:\Users\Home\Desktop\project\node_modules\undertaker\lib\task.js:13:8)
    at Object.<anonymous> (C:\Users\Home\Desktop\project\gulpfile.js:5:6)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Martovitskiy, 2019-02-05
@Taron4uk

You have Gulp 4 installed, and the syntax is Gulp 3. In 4, a new task execution system - gulp.parallel and gulp.series
See here and here
In addition:

function browserSync(done) {
  browsersync.init({
    server: {
      baseDir: "./"
    },
    port: 3000,
    notify: false 
  });
  done();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question