Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Task "default" is not in your gulpfile

Tags:

I run 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     }); }); 
like image 995
Jessie Emerson Avatar asked Dec 26 '16 10:12

Jessie Emerson


People also ask

How do I run Gulpfile in Visual Studio?

Run a Gulp Task in Visual Studio CodeType "Run Task" and select it, which will bring up a list of tasks configured in Gulp. Choose the Gulp Task you want to run! Most of your Gulp Tasks will probably be automated using gulp watch, but manual Gulp Tasks can easily be run within Visual Studio Code.

What is a Gulpfile?

A gulpfile is a file in your project directory titled gulpfile. js (or capitalized as Gulpfile. js , like Makefile), that automatically loads when you run the gulp command.

Where do I put Gulpfile js?

Writing the First Gulp Task. All Gulp configuration goes in a file called gulpfile. js located at the root of the project. The pattern for writing tasks is that you first load a plugin you're about to use and then define a task that is based on that plugin.


1 Answers

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

To solve define a default task, you can add the task you actually want to run as the dependency like so:

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

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

like image 165
SnailCrusher Avatar answered Oct 06 '22 08:10

SnailCrusher