N
N
narem2020-01-17 12:52:57
Node.js
narem, 2020-01-17 12:52:57

Gulp version conflict, how to fix?

const gulp = require('gulp'),
  sass = require('gulp-sass'),
  autoprefixer = require('gulp-autoprefixer'),
  cssnano = require('gulp-cssnano');

gulp.task('scss', function(){
  return gulp
  .src('dev/scss/**/*.scss')
  .pipe(sass())
  .pipe(
    autoprefixer(['last 15 versions', '>1%', 'ie 8','ie 7'], {
      cascade: true
    })
    )
  .pipe(cssnano())
  .pipe(gulp.dest('dist/style'))
});

gulp.task('default', ['scss'], function(){
  gulp.watch('dev/sass/**/*.scss',['scss'])
});

gulp assert.js
:374
throw err;
^
AssertionError [ERR_ASSERTION]: Task function must be specified
at Gulp.set [as _setTask] (/home/admin/web/93.170.130.182/public_html/node_modules/undertaker/lib/set-task.js:10:3)
at Gulp.task (/home/admin/web/93.170.130.182/public_html/node_modules/undertaker/lib/task.js:13:8)
at Object. (/home/admin/web/93.170.130.182/public_html/gulpfile.js:19:6)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js :727:14)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at execute (/usr/local/lib/node_modules/gulp- cli/lib/versioned/^4.0.0/index.js:36:18) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}

as I understand this error, because the code is for the old version of gulp, but I can’t understand what exactly is wrong, can anyone tell me?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
narem, 2020-01-17
@narem

For myself and for other comrades who will google

const gulp = require('gulp'),
  sass = require('gulp-sass'),
  autoprefixer = require('gulp-autoprefixer'),
  cssnano = require('gulp-cssnano');

gulp.task('scss', function(){
  return gulp
  .src('dev/scss/**/*.scss')
  .pipe(sass())
  .pipe(
    autoprefixer(['last 15 versions', '>1%', 'ie 8','ie 7'], {
      cascade: true
    })
    )
  .pipe(cssnano())
  .pipe(gulp.dest('dist/style'))
});

gulp.task('default', gulp.parallel('scss'), function(){
  gulp.watch('dev/sass/**/*.scss',gulp.parallel('scss'))
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question