Task 'default' is not in your gulpfile

Jess McKenzie picture Jess McKenzie · Apr 18, 2016 · Viewed 8.7k times · Source

I have tried the NPM install and removed the node_modules folder however I am still getting the error when I run gulp etc

Have I missed something out of my file?

var gulp   = require('gulp');
var elixir = require('laravel-elixir');
var uglify = require('gulp-uglify');


    /*
     |--------------------------------------------------------------------------
     | Elixir Asset Management
     |--------------------------------------------------------------------------
     |
     */


    /*
     |--------------------------------------------------------------------------
     | Elixir JS Asset Management
     |--------------------------------------------------------------------------
     |
     */

     elixir.extend('uglify', function(){

        gulp.task('uglify', function(){

            gulp.src('public/admin/js/*.js')
                .pipe(uglify())
                .pipe(ext('-min.js'))
                .pipe(gulp.dest('public/admin/js'));
        });
            return this.queueTask('uglify');
     });

Answer

franmartosr picture franmartosr · Apr 18, 2016

Like some people say in the comments, you don't have a task in gulp called "default". You have 2 options:

  • Create a 'default' task:

    var gulp   = require('gulp');
    var elixir = require('laravel-elixir');
    var uglify = require('gulp-uglify');
    
    
    /*
     |--------------------------------------------------------------------------
     | Elixir Asset Management
     |--------------------------------------------------------------------------
     |
     */
    
    
    /*
     |--------------------------------------------------------------------------
     | Elixir JS Asset Management
     |--------------------------------------------------------------------------
     |
     */
    
    elixir.extend('uglify', function(){
    
        gulp.task('uglify', function(){
    
            gulp.src('public/admin/js/*.js')
                .pipe(uglify())
                .pipe(ext('-min.js'))
                .pipe(gulp.dest('public/admin/js'));
        });
    return this.queueTask('uglify');
    });
    
    elixir.extend('default', function(){
    
        gulp.task('default', function(){
            //Your code here!
        });
    return this.queueTask('default');
    });
    
  • Call Gulp with "gulp uglify" instead of just "gulp" to run the task that you already have.

I do not have knowlege about Laravel so I hope this answer serves you.