typeerror dest.on is not a function at destroyabletransform.readable.pipe code example

Example: dest.on is not a function at DestroyableTransform.Readable.pipe

var path = require('path')
var gulp = require('gulp')
var imagemin = require('imagemin')

var merge2 = require('merge-stream');
var merge = require('merge2');

var gm = require('gulp-gm');

var spritesmith = require('gulp.spritesmith');
var spritesmash = require('gulp-spritesmash');
var pngquant = require('imagemin-pngquant');

var rename = require("gulp-rename");
var source = "./testorig/"
var dest = "./test/"

gulp.task('sprites', function () {
    var files = gulp.src(source+'/*.png')

    // Short version:

    var spriteData = files
        .pipe(spritesmith({
            imgName: 'sprite.png',
            cssName: 'sprite.css'
        }));

    var buffer = require('vinyl-buffer');
    var imgStream = spriteData.img
        .pipe(buffer())
        .pipe(imagemin({
            progressive: true,
            interlaced: true,
            optimizationLevel: 7,
            svgoPlugins: [{
                removeViewBox: false
            }, {
                removeUselessStrokeAndFill: false
            }],
            plugins: [
                pngquant({
                    quality: [70,90],
                    speed: 1
                })
            ]
        }))
        .pipe(gulp.dest(dest));
});