A
A
Artur Harutyunyan2018-12-24 21:05:19
Sass
Artur Harutyunyan, 2018-12-24 21:05:19

Gulp not working, throwing an error?

installed correctly, I run the code in the gulpfile.js file taken from the browsersync website, here is the code:

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: "src/"
    });

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

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

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

____________________________________________________________
I heard that in version 4 of gulp there is a different syntax, but I could not master it, what needs to be changed to make it work???
in the package.json file the following info:
{
  "name": "project",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Artur",
  "license": "ISC",
  "devDependencies": {
    "browser-sync": "^2.26.3",
    "gulp": "^4.0.0",
    "gulp-sass": "^4.0.2"
  }
}

________________________________________________________________________
Here is the
PS D:\8 error itself. Frontend\project> gulp
assert.js:42
throw new errors.AssertionError({
^
AssertionError [ERR_ASSERTION]: Task function must be specified
at Gulp.set [as _setTask] (D:\8. Frontend\project\node_modules\undertaker\ lib\set-task.js:10:3)
at Gulp.task (D:\8.Frontend\project\node_modules\undertaker\lib\task.js:13:8)
at Object.(D:\8.Frontend \project\gulpfile.js:6:6)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js :566:32)
at tryModuleLoad(module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alex, 2018-12-24
@vachunya

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

gulp.task('sass', function(done) {
    gulp.src("scr/scss/*.scss")
        .pipe(sass())
        .pipe(gulp.dest("scr/css"))
        .pipe(browserSync.stream());


    done();
});

gulp.task('serve', function(done) {

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

    gulp.watch("scr/sass/*.sass", gulp.series('sass'));
    gulp.watch("scr/*.html").on('change', () => {
      browserSync.reload();
      done();
    });
  

    done();
});

gulp.task('default', gulp.series('sass', 'serve'));

C
coderxx, 2018-12-24
@coderxx

Such questions began to appear every day. The syntax has changed in Gulp 4. The parallel and series properties appeared, square brackets disappeared. The old hapfiles don't work. Everything is detailed here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question