Answer the question
In order to leave comments, you need to log in
How to fix Gulp 3 code for Gulp 4?
Please help me correct Gulp 3 code for Gulp 4
"use strict";
var gulp = require("gulp");
var less = require("gulp-less");
var plumber = require("gulp-plumber");
var postcss = require("gulp-postcss");
var autoprefixer = require("autoprefixer");
var server = require("browser-sync").create();
gulp.task("style", function() {
gulp.src("less/style.less")
.pipe(plumber())
.pipe(less())
.pipe(postcss([
autoprefixer()
]))
.pipe(gulp.dest("css"))
.pipe(server.stream());
});
gulp.task("serve", ["style"], function() {
server.init({
server: ".",
notify: false,
open: true,
cors: true,
ui: false
});
gulp.watch("less/**/*.less", ["style"]);
gulp.watch("*.html").on("change", server.reload);
});
Выдает ошибку
<code>λ npm start
> [email protected]0.1.0 start C:\Users\Наташа\github\mishka
> gulp serve
assert.js:378
throw err;
^
AssertionError [ERR_ASSERTION]: Task function must be specified
at Gulp.set [as _setTask] (C:\Users\Наташа\github\mishka\node_modules\undertaker\lib\set-task.js:10:3)
at Gulp.task (C:\Users\Наташа\github\mishka\node_modules\undertaker\lib\task.js:13:8)
at Object.<anonymous> (C:\Users\Наташа\github\mishka\gulpfile.js:21:6)
at Module._compile (internal/modules/cjs/loader.js:1121:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
at Module.load (internal/modules/cjs/loader.js:976:32)
at Function.Module._load (internal/modules/cjs/loader.js:884:14)
at Module.require (internal/modules/cjs/loader.js:1016:19)
at require (internal/modules/cjs/helpers.js:69:18)
at execute (C:\Users\Наташа\github\mishka\node_modules\gulp\node_modules\gulp-cli\lib\versioned\^4.0.0\index.js:36:18) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected]0.1.0 start: `gulp serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected]0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Наташа\AppData\Roaming\npm-cache\_logs\2019-12-13T15_06_52_221Z-debug.log</code>
Answer the question
In order to leave comments, you need to log in
Try
var gulp = require("gulp");
var less = require("gulp-less");
var postcss = require("gulp-postcss");
var autoprefixer = require("autoprefixer");
var server = require("browser-sync").create();
gulp.task("style", function() {
gulp.src("less/style.less")
.pipe(less())
.pipe(postcss([
autoprefixer()
]))
.pipe(gulp.dest("css"))
.pipe(server.stream());
});
gulp.task("serve", function() {
server.init({
server: ".",
notify: false,
open: true,
cors: true,
ui: false
})
gulp.watch("less/**/*.less", gulp.series('style'))
gulp.watch("*.html").on("change", server.reload)
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question