L
L
Lobster2021-05-31 19:42:43
JavaScript
Lobster, 2021-05-31 19:42:43

TypeError: dest.on is not a function! But why?

Everything seems to be according to the documentation, but it does not work. I don't understand. Help / explain to someone is not difficult.

// Определяем константы Gulp
const { src, dest, parallel, series, watch } = require('gulp');

const browserSync = require('browser-sync').create();
const concat = require('concat');
const uglify = require('gulp-uglify-es').default;

function browsersync() {
    browserSync.init({
        server: { baseDir: 'app/' },
        notify: false,
        online: true
    })
}

function scripts() {
    return src([ // Берём файлы из источников
        'node_modules/jquery/dist/jquery.min.js',
        'app/js/app.js',
    ])
        .pipe(concat('app.min.js'))
        .pipe(uglify())
        .pipe(dest('app/js/'))
        .pipe(browserSync.stream())
}

exports.browsersync = browsersync;
exports.scripts = scripts;


Everything related to the error from the console:
C:\Users\10XSpeed\Desktop\my-project>gulp scripts
[19:38:12] Using gulpfile ~\Desktop\my-project\gulpfile.js
[19:38:12] Starting 'scripts'...
[19:38:12] 'scripts' errored after 15 ms
[19:38:12] TypeError: dest.on is not a function
    at DestroyableTransform.Readable.pipe (C:\Users\10XSpeed\Desktop\my-project\node_modules\readable-stream\lib\_stream_readable.js:564:8)
    at scripts (C:\Users\10XSpeed\Desktop\my-project\gulpfile.js:27:10)
    at scripts (C:\Users\10XSpeed\Desktop\my-project\node_modules\undertaker\lib\set-task.js:13:15)
    at bound (domain.js:416:15)
    at runBound (domain.js:427:12)
    at asyncRunner (C:\Users\10XSpeed\Desktop\my-project\node_modules\async-done\index.js:55:18)
    at processTicksAndRejections (internal/process/task_queues.js:77:11)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lobster, 2021-05-31
@YoManYo

Understood. Somehow I installed the wrong package. Now everything works. The question is closed!

K
Kentavr16, 2021-05-31
@Kentavr16

So, according to the documentation:
https://www.browsersync.io/docs/gulp/
Pay attention to how browsersync is declared. Or rather gulp. task

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question