V
V
Vlad Shved2018-09-04 04:20:45
Node.js
Vlad Shved, 2018-09-04 04:20:45

Why is task gulp not working?

The task itself:

var gulp = require('gulp'),
    mainCSS = require('gulp-clean-css'),
    sass = require('gulp-sass'),
    browserSync = require('browser-sync').create();

gulp.task('serve', ['sass'], function() {

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

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

gulp.task('sass', function() {
    return gulp.src("app/sass/*.sass")
        .pipe(sass())
        .pipe(gulp.dest("app/css"))
        .pipe(browserSync.stream());
});

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

package.json:
{
  "name": "myproject",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "browser-sync": "^2.24.7",
    "gulp": "^3.9.1",
    "gulp-clean-css": "^3.10.0",
    "gulp-sass": "^4.0.1"
  }
}

Error in gulp:
C:\Users\Vlad\Documents\it\myproject>gulp
C:\Users\Vlad\Documents\it\myproject\gulpfile.js:23
gulp.task('default', [serve]);
^
ReferenceError: serve is not defined
at Object. (C:\Users\Vlad\Documents\it\myproject\gulpfile.js:23:23)
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:20:18)
at Liftoff.handleArguments (C:\Users\Vlad\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:116:3)
at liftoff.execute (C:\Users\Vlad\AppData\Roaming\npm\node_modules\gulp\node_modules\liftoff\index.js:203:12)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question