The "default" task is not in your gulpfile

I am running gulp in my console. I got this error:

Task 'default' is not in your gulpfile

My gulpfile looks just fine:

var gulp = require('gulp'), LiveServer = require('gulp-live-server'), browserSync = require('browser-sync'); gulp.task('live-server', function () { var server = new LiveServer('server/main.js'); server.start(); }); gulp.task('serve', ['live-server'], function () { browserSync.init(null, { proxy: "http://localhost:3000", port: 9001 }); }); 
+5
source share
4 answers

When you just run gulp in your console, it will look for the default job to run. You have defined only live-server and serve as tasks.

To solve the default task, you can add the task that you really want to run, as a dependency, for example:

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

Now, if you run gulp , it will run the default task, which in turn will run the serve task. Alternatively, you can just run gulp serve , and it will also work.

+18
source

Please indicate this in the gulp file.

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

Hope this helps.

+1
source

Create a default task and add the tasks you want to run by default:

 gulp.task("default", function () { gulp.start("serve"); }); 
0
source

I had a similar problem and this is my gulp file

My gulp file

Instead of setting the default, I make a direct call to the serve task.

In cmd - gulp serve

By direct calling the service, it will cause me the task of synchronizing with the browser.

Hope this would be helpful for someone :)

0
source

Source: https://habr.com/ru/post/1261899/


All Articles