Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Glup V4.0.0 'gulp start' is not a function

Tags:

angularjs

gulp

I have this below gulpfile.js. When i run the app using 'gulp start' then it is showing start is not a function. Glup-cli version i'm using V4.0.0

const gulp = require('gulp');
const concat = require('gulp-concat');
const browserSync = require('browser-sync').create();

const scripts = require('./scripts');
const styles = require('./styles');

// Some pointless comments for our project.

var devMode = false;

gulp.task('css', function() {
    gulp.src(styles)
        .pipe(concat('main.css'))
        .pipe(gulp.dest('dist/css'))
        .pipe(browserSync.reload({
            stream: true
        }));
});

gulp.task('js', function() {
    gulp.src(scripts)
        .pipe(concat('scripts.js'))
        .pipe(gulp.dest('./dist/js'))
        .pipe(browserSync.reload({
            stream: true
        }));
});

gulp.task('html', function() {
    return gulp.src('./src/templates/**/*.html')
        .pipe(gulp.dest('./dist/'))
        .pipe(browserSync.reload({
            stream: true
        }));
});

gulp.task('build', function() {
    gulp.start(['css', 'js', 'html'])
});

gulp.task('browser-sync', function() {
    browserSync.init(null, {
        open: false,
        server: {
            baseDir: 'dist',
        }
    });
});

gulp.task('start', function() {
    devMode = true;
    gulp.start(['build', 'browser-sync']);
    gulp.watch(['./src/css/**/*.css'], ['css']);
    gulp.watch(['./src/js/**/*.js'], ['js']);
    gulp.watch(['./src/templates/**/*.html'], ['html']);
});
like image 307
boycod3 Avatar asked Jan 19 '19 07:01

boycod3


People also ask

What is gulp 4?

gulp is a JavaScript-based build tool for automating the execution of web development tasks. Actually, gulp can automate anything that may be done from Node. js, and since Node. js can run shell commands, gulp may actually be used to automate any task.

How do you define a task in Gulp?

A private task looks and acts like any other task, but an end-user can't ever execute it independently. To register a task publicly, export it from your gulpfile. const { series } = require('gulp'); // The `clean` function is not exported so it can be considered a private task.

What is Gulp watch command?

watch() Allows watching globs and running a task when a change occurs. Tasks are handled uniformly with the rest of the task system.


1 Answers

gulp.start has been deprecated in v4. Depending on your needs, you can use gulp.series or gulp.parallel instead.

- gulp.task('start', function() {
-   devMode = true;
-   gulp.start(['build', 'browser-sync']);
+ gulp.task('start', gulp.series('build', 'browser-sync'), function(done) {
+   devMode = true;
    gulp.watch(['./src/css/**/*.css'], ['css']);
    gulp.watch(['./src/js/**/*.js'], ['js']);
    gulp.watch(['./src/templates/**/*.html'], ['html']);
  });

This question is probably a duplicated of this one, but since that question hasn't got an accepted answer I'll just echo Mark's answer.

like image 162
Derek Nguyen Avatar answered Sep 23 '22 13:09

Derek Nguyen