Mirami97
@Mirami97
студент

Не работает Gulp?

Код в gulpfile.js

const { src, dest, watch, parallel } = require('gulp');
const scss = require('gulp-sass');
const concat = require('gulp-concat');
const browserSync = require('browser-sync').create();

function browsersync() {
browserSync.init({
server: {
baseDir: "app/"
}
});
}

function styles() {
return src('app/scss/style.scss')

.pipe(scss({outputStyle: 'compressed'}))
.pipe(concat('style.min.css'))
.pipe(dest('app/css'))
.pipe(browserSync.stream())
}

function watching() {
watch(['app/scss/**/*.scss'], styles)
watch(['app/*.html']).on('change', browserSync.reload)
}

exports.styles = styles;
exports.watching = watching;
exports.browsersync = browsersync;

exports.default = parallel('browsersync', 'watching');

В консоле запускаю gulp default. Но выводит ошибку

AssertionError [ERR_ASSERTION]: Task never defined: browsersync
at getFunction (C:\Users\mmirxomitov\Desktop\test-gulp\node_modules\undertaker\lib\helpers\normalizeArgs.js:21:9)
at map (C:\Users\mmirxomitov\Desktop\test-gulp\node_modules\arr-map\index.js:20:14)
at normalizeArgs (C:\Users\mmirxomitov\Desktop\test-gulp\node_modules\undertaker\lib\helpers\normalizeArgs.js:30:10)
at Gulp.parallel (C:\Users\mmirxomitov\Desktop\test-gulp\node_modules\undertaker\lib\parallel.js:13:14)
at Object. (C:\Users\mmirxomitov\Desktop\test-gulp\gulpfile.js:32:19)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}

Было установлена версия gulp 4.1.0
Код в package.json
{
"name": "test-gulp",
"version": "1.0.0",
"description": "test about gulp",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Mirjalol",
"license": "ISC",
"devDependencies": {
"browser-sync": "^2.26.14",
"gulp": "^4.0.2",
"gulp-concat": "^2.6.1",
"gulp-file-include": "^2.3.0",
"gulp-sass": "^4.1.0"
}
}

Из-за чего может быт такая ошибка?
  • Вопрос задан
  • 122 просмотра
Решения вопроса 1
approximate_solution
@approximate_solution
JS Developer. Angular\React\Vue\Ember
exports.default = parallel('browsersync', 'watching');

Кавычки не нужны. Правильно:
exports.default = parallel(browsersync, watching);
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы