Как исправить ошибку «dest.on не функция» в gulp - PullRequest
0 голосов
/ 17 июня 2019

Я настраивал свой файл gulp и столкнулся со следующей ошибкой:

 Starting 'html'... 
 [23:44:40] Finished 'html' after 8.42 ms
 [23:44:40] Finished 'html' after 4.54 ms
 [23:44:40] Starting 'html'...
 [23:44:40] 'html' errored after 646 μs
 [23:44:40] TypeError: dest.on is not a function
at DestroyableTransform.Stream.pipe (internal/streams/legacy.js:30:8)
at Gulp.<anonymous> (D:\web_forum\gulpfile.js:17:10)
at module.exports (D:\web_forum\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (D:\web_forum\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (D:\web_forum\node_modules\orchestrator\index.js:214:10)
at Gulp.Orchestrator.start (D:\web_forum\node_modules\orchestrator\index.js:134:8)
at Gulp.<anonymous> (D:\web_forum\node_modules\gulp\index.js:36:18)
at Gaze.<anonymous> (D:\web_forum\node_modules\glob-watcher\index.js:18:14)
at emitTwo (events.js:126:13)
at Gaze.emit (events.js:214:7)
[23:44:40] Starting 'html'...
[23:44:40] Finished 'html' after 4.21 ms
[Browsersync] Reloading Browsers...

эта ошибка была сгенерирована после изменения de html-части исходного кода. трассировка была инициирована задачей gulp.watch ()

Я использую следующий gulpfile:

const gulp = require('gulp');
const uglify = require('gulp-uglify');
const sass = require('gulp-sass');
const concat = require('gulp-concat');
const htmlPartial = require('gulp-html-partial');
const htmlmin = require('gulp-htmlmin');
const cleanCSS = require('gulp-clean-css');
var browserSync = require('browser-sync').create();
var runSequence = require('run-sequence');

gulp.task('html', function(){
    return gulp.src('src/html/*.html')
        .pipe(htmlPartial({
            basePath: 'src/html/partials/'
        }))
        .pipe(gulp.dest('dist/'))
        .pipe(browserSync.reload());

});

gulp.task('build_html', function(){
    return gulp.src('src/html/*.html')
        .pipe(htmlPartial({
            basePath: 'src/html/partials/'
        }))
        .pipe(htmlmin({collapseWhitespace: true}))
        .pipe(gulp.dest('dist/'));
});

gulp.task('build_sass', function(){
    return gulp.src('src/sass/*scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(concat('style.min.css'))
        .pipe(cleanCSS({compatibility: 'ie8'}))
        .pipe(gulp.dest('dist/css'));
});

gulp.task('sass', function(){
    return gulp.src('src/sass/*scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(concat('style.min.css'))
        .pipe(gulp.dest('dist/css'));
});

gulp.task('scripts', function(){
    return gulp.src('src/js/*.js')
        .pipe(concat('main.js'))
        .pipe(gulp.dest('dist/js'));
});

gulp.task('build_scripts', function(){
    return gulp.src('src/js/*.js')
        .pipe(concat('main.js'))
        .pipe(uglify())
        .pipe(gulp.dest('dist/js'));
});

gulp.task('images', function(){
    return gulp.src('src/images/*')
        .pipe(gulp.dest('dist/images'));
});

gulp.task('serve', function() {
    browserSync.init({
        server: "./dist"
    });

    gulp.watch("src/html/**/*.html", ['html']);
    gulp.watch("src/js/*.js", ['scripts']);
    gulp.watch("src/sass/*.scss", ['sass']);
    gulp.watch("src/images/*", ['images']);
});

gulp.task (serve) выполнялся в консоли через gulp-клиент, это запускает потоковый сервер и запускает обработчики наблюдения. ошибка происходит в gulp.task (html). другие задачи пока не содержат потоковых команд.

Кто-нибудь знает, как это исправить?

спасибо

...