sindresorhus / gulp-imagemin

Minify PNG, JPEG, GIF and SVG images
MIT License
1.9k stars 157 forks source link

TypeError in plugin "gulp-imagemin": function_ is not a function #373

Closed RomanStupnitskyi closed 2 years ago

RomanStupnitskyi commented 2 years ago

My code:

import webp from 'gulp-webp';
import imagemin from 'gulp-imagemin';

export const img = () => {
    return gulp.src(path.src.img)
        .pipe(plugins.plumber(
            plugins.notify.onError({
                title: "IMAGES",
                message: "Error: <%= error.message %>"
            })
        ))
        .pipe(plugins.newer(path.build.img))
        .pipe(webp())
        .pipe(gulp.dest(path.build.img))
        .pipe(gulp.src(path.src.img))
        .pipe(plugins.newer(path.build.img))
        .pipe(imagemin({
            progressive: true,
            svgoPlugins: [{ removeViewBox: false }],
            interlaced: true,
            optimizationLevel: 3
        }))
        .pipe(gulp.dest(path.build.img))
        .pipe(gulp.src(path.src.svg))
        .pipe(gulp.dest(path.build.img))
        .pipe(plugins.browsersync.stream());
}

Path is global variable:

import * as nodePath from 'path';

const rootFolder = nodePath.basename(nodePath.resolve());
const ftp = ''

const srcFolder = './src';
const buildFolder = './build';

export const path = {
    build: {
        html: `${buildFolder}/`,
        css: `${buildFolder}/css`,
        js: `${buildFolder}/js`,
        img: `${buildFolder}/img`
    },
    src: {
        html: `${srcFolder}/*.html`,
        scss: `${srcFolder}/scss/style.scss`,
        js: `${srcFolder}/js/index.js`,
        svg: `${srcFolder}/img/**/*.svg`,
        img: `${srcFolder}/img/*.{jpg,jpeg,png,gif,webp}`
    },
    watch: {
        html: `${srcFolder}/**/*.html`,
        scss: `${srcFolder}/scss/**/*.scss`,
        js: `${srcFolder}/js/**/*.js`,
        img: `${srcFolder}/img/*.{jpg,jpeg,png,svg,gif,ico,webp}`
    },
    srcFolder,
    buildFolder,
    rootFolder,
    ftp
}

Plugins is global variable:

import replace from 'gulp-replace';
import plumber from 'gulp-plumber';
import notify from 'gulp-notify';
import browsersync from 'browser-sync';
import newer from 'gulp-newer';

export const plugins = {
    replace, plumber, notify, browsersync, newer
}

Error message:

[11:30:10] TypeError in plugin "gulp-imagemin"
Message:
    function_ is not a function
Details:
    fileName: C:\Users\rbamb\OneDrive\Документы\Gulp\src\img\softskills.png
    domainEmitter: [object Object]
    domainThrown: false
MikeMcC399 commented 1 year ago

@RomanStupnitskyi

I have a user on a Mac M1 reporting the same error.

Did you somehow solve this issue which you closed on Sep 4? If yes, what did you do to solve it?

Were you by any chance also running under macOS / Apple Silicon without Rosetta emulation installed? We subsequently found that installing Rosetta 2 resolved the issue.

medoingthings commented 11 months ago

Have the same issue on my M2 MacBook Pro. Build throws the above mentioned error on my local machine, but on the Bitbucket Pipeline it build perfectly fine.