[gulp imagimine插件优化图像时出现throwinf错误

问题描述 投票:0回答:1

我有这样的任务

gulp.task('images', () => {
  return gulp.src('assets/images/**/*')
      .pipe($.cache($.imagemin()))
    .pipe(gulp.dest('public/build/images'));
});

并且对我来说,这行.pipe($.cache($.imagemin()))抛出错误:

events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: write callback called multiple times
    at DestroyableTransform.afterTransform (/var/www/vhosts/devgenix/node_modules/readable-stream/lib/_stream_transform.js:84:31)
    at EventEmitter.signals.on.err (/var/www/vhosts/devgenix/node_modules/gulp-cache/lib/index.js:451:7)
    at EventEmitter.emit (events.js:182:13)
    at DestroyableTransform.onError (/var/www/vhosts/devgenix/node_modules/gulp-cache/lib/index.js:288:15)
    at Object.onceWrapper (events.js:273:13)
    at DestroyableTransform.emit (events.js:187:15)
    at Immediate.<anonymous> (/var/www/vhosts/devgenix/node_modules/through2-concurrent/through2-concurrent.js:37:14)
    at runCallback (timers.js:706:11)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)

但是对于其他使用其计算机的开发人员,一切正常。

我正在带有预安装节点的自定义高山docker容器下运行所有​​代码(其他开发人员没有),所以这可能是个问题,我只需要安装一些缺少的依赖项,但我无法弄清楚出了什么问题。] >

我的码头工人文件实际上是用于带有节点的PHP,这是码头工人文件的内容:

FROM php:7.1-fpm-alpine

ENV ZMQ_VERSION 4.3.1

ENV BUILD_DEPS autoconf file gcc libc-dev make g++ pkgconf re2c git

RUN apk add --update --no-cache --virtual .build-deps $BUILD_DEPS

# Error code: 127
RUN apk add --no-cache --virtual .php-build-deps \
 nasm \
        libsodium \
        freetype-dev \
        libmcrypt-dev \
        postgresql-dev  \
        libxml2-dev  \
        zlib-dev cyrus-sasl-dev libmemcached-dev   \

        # the next line is for node and npm packages (node-sass requires python/make/g++ to build something)

        python \
        && apk add --update nodejs nodejs-npm \
        # for GD
        bash \
        freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev \

        # just good to have installed
        ca-certificates wget \

        ## Install git (we'll never delete it)
        #&& apk add --no-cache git \

        && docker-php-ext-configure gd \
            --with-gd \
            --with-freetype-dir=/usr/include/ \
            --with-png-dir=/usr/include/ \
            --with-jpeg-dir=/usr/include/ \

        && NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) \

        ## Installable modules
        && docker-php-ext-install -j${NPROC} iconv mcrypt bcmath pdo_mysql opcache pgsql pdo_pgsql soap pcntl exif zip gd \
        && apk del --no-cache freetype-dev libpng-dev libjpeg-turbo-dev \

        ## Memcached
        && git clone https://github.com/php-memcached-dev/php-memcached.git \
        && cd php-memcached \
        && git checkout php7 \
        && phpize \
        && ./configure --disable-memcached-sasl \
        && make \
        && cp modules/memcached.so $(php-config --extension-dir) \
        && docker-php-ext-enable memcached \


        ## Composer
        && cd ~ \
        && curl -sS https://getcomposer.org/installer | php \
        && mv composer.phar /usr/local/bin/composer \

        ## Gulp
        && npm install -g gulp \

        ## Cleanup
        && rm -rf /var/cache/apk/*

RUN docker-php-ext-configure calendar && docker-php-ext-install calendar

ADD www.conf /usr/local/etc/php-fpm.d
ADD php-fpm.conf /usr/local/etc
ADD php.ini /usr/local/etc/php/

WORKDIR /var/www/vhosts/devgenix/

#EXPOSE 22

CMD ["php-fpm", "--fpm-config", "/usr/local/etc/php-fpm.conf"]

也许有人有什么想法为什么对我不起作用?谢谢!

更新

npm版本:6.4.1gulp版本:3.9.1gulp-imagemin版本:4.1.0

我有这样的任务,gulp.task('images',()=> {return gulp.src('assets / images / ** / *').pipe($。cache($。imagemin()) ).pipe(gulp.dest('public / build / images'));});并抛出...

docker gulp
1个回答
0
投票

我通过将libjpeg-turbo libjpeg-turbo-dev libpng libpng-dev automake依赖项添加到我的docker文件中解决了该问题

© www.soinside.com 2019 - 2024. All rights reserved.