S
S
Shell1542019-05-04 05:41:56
Less
Shell154, 2019-05-04 05:41:56

Why does the 'Did you forget to signal async completion' error occur?

[09:26:53] The following tasks did not complete: less
[09:26:53] Did you forget to signal async completion?

const gulp = require('gulp');
const less1 = require('gulp-less');

function less() {
  return gulp.src('./less/*.less')
    .pipe(less1())
    .pipe(gulp.dest('./css/'))
}

gulp.task('less', less1);

By the way, if I call the variable less, then the task does not work. Why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
ProgerSoft, 2019-06-25
@ProgerSoft

Your function is called less, and you call the less1 function in the task.
Here is the corrected code...

const
  gulp = require('gulp'),
  less1 = require('gulp-less');

function less() {
  return gulp.src('./less/*.less')
    .pipe(less1())
    .pipe(gulp.dest('./css/'))
}

gulp.task('less', less);

Calling a variable less doesn't work, because when you call the less function in the less function, js doesn't know to call the less function (
function less() {...}
) or connected less (
const less = require('gulpless')
).
If you want to name the variable less and make it work, use this code:
const
  gulp = require('gulp'),
  less = require('gulp-less');

gulp.task('less', () => {
  return gulp.src('./less/*.less')
    .pipe(less())
    .pipe(gulp.dest('./css/')
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question