Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imagemin:dist Error #254

Closed
victoy opened this issue Sep 22, 2014 · 30 comments
Closed

imagemin:dist Error #254

victoy opened this issue Sep 22, 2014 · 30 comments

Comments

@victoy
Copy link

victoy commented Sep 22, 2014

Hi,
When I tried to do "grunt imagemin:dist", the below error occurred.

Task source: ~/MyApp/node_modules/grunt-contrib-imagemin/tasks/imagemin.js
Fatal error: Object #< DestroyableTransform > has no method 'apply'

The version of grunt-contrib-imagemin is 0.8.1.
And I use through2 for image stream. Actually, the angular fullstack use through2 for it.

Thanks.

@RavenHursT
Copy link

I'm having the same issue. Would love to get some feedback on this.

@RavenHursT
Copy link

@RavenHursT
Copy link

Well.. I got it working.. see my answer on stack overflow.

@kevva
Copy link
Member

kevva commented Sep 23, 2014

Well, did you get any errors upon installation?

@RavenHursT
Copy link

I saw something to do w/ that png library on npm install.. so that's what gave me the breadcrumb to install it.

@kevva
Copy link
Member

kevva commented Sep 23, 2014

So, the pngquant binary failed. OS?

@RavenHursT
Copy link

I think that was it. I'm sorry.. I can't remember the exact error I saw..

My build server is old.. Ubuntu 11

Works flawlessly on my mac.

@kevva
Copy link
Member

kevva commented Sep 23, 2014

We simply can't guarantee that all binaries will work on all OS, especially if they are that old. I'm using Ubuntu 14.04 and all binaries works seamlessly.

You should pay attention to messages during installation and follow the instructions.

@victoy
Copy link
Author

victoy commented Sep 23, 2014

But.. my os is mac OS x version 10.9.4.
I think mine is not that old. When did you get the error message related in png?

@RavenHursT
Copy link

This was a matter of a missing library, not user error not by not "paying attention".

If that library is missing, it might be a good idea to throw a more meaningful error during the grunt build. It was just by chance that I connected the install messages w/ the grunt error in the OP.

@victoy, durring npm install, there's some packages that complain about "pre-build tests" failing, or something like that. One of them mentions the library that I put in my stack overflow answer.

@kevva
Copy link
Member

kevva commented Sep 24, 2014

@RavenHursT, that library is only needed if the pre-build fails since it'll try and build it. The pre-build checks if the precompiled binary works.

@victoy
Copy link
Author

victoy commented Sep 24, 2014

@RavenHursT, I checked your stack overflow answer. Thanks.

@gcallaghan
Copy link

I am getting a similar error on OSX 10.9

$ npm install --save-dev imagemin-pngquant
....

pngquant-bin@1.0.1 postinstall /Users/grant/src/.../website/node_modules/imagemin-pngquant/node_modules/pngquant-bin
node lib/install.js

downloading : https://raw.github.com/imagemin/pngquant-bin/v1.0.1/vendor/osx/pngquant
progress : [====================] 100% 0.0s
✔ pre-build test passed successfully!
imagemin-pngquant@2.0.0 node_modules/imagemin-pngquant
├── is-png@1.0.0
├── through2@0.6.2 (xtend@4.0.0, readable-stream@1.0.32)
└── pngquant-bin@1.0.1 (log-symbols@1.0.1, bin-wrapper@1.0.4, bin-build@1.0.1)

$ grunt imagemin:dist
Running "imagemin:dist" (imagemin) task
Fatal error: Object # has no method 'apply'
TypeError: Object # has no method 'apply'
at next (/Users/grant/src/.../website/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/ware/lib/index.js:68:8)
at /Users/grant/src/.../website/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/index.js:40:5
at /Users/grant/src/..../website/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/exec-buffer/index.js:117:25
at CB (/Users/grant/src/.../website/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/exec-buffer/node_modules/rimraf/rimraf.js:68:5)
at /Users/grant/src/.../website/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/exec-buffer/node_modules/rimraf/rimraf.js:99:12
at Object.oncomplete (fs.js:107:15)

@minhtranite
Copy link

Same issue with message:

Warning: Running "imagemin:dist" (imagemin) task
    Fatal error: Object #<Object> has no method 'apply'

My grunt taks config:

var mozjpeg = require('imagemin-mozjpeg');;
...
imagemin: {
      options: {
        optimizationLevel: 5,
        use: [mozjpeg()]
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/images',
          src: '**/*.{gif,jpeg,jpg,png}',
          dest: '<%= config.dist %>/images'
        }]
      }
    }

I'm use Ubuntu 12.04

@paulbjensen
Copy link

Same for Mac OS X 10.9.5

@paulbjensen
Copy link

Fixed it by doing the following:

wget https://raw.github.com/imagemin/pngquant-bin/v1.0.1/vendor/osx/pngquant
sudo cp pngquant /usr/local/bin/
sudo chmod +x /usr/local/bin/pngquant

After doing this, I no longer get that error

@Rrrapture
Copy link

I don't get this error locally (Mac OS X 10.8.5), but I do get it when I attempt a push to Heroku, using a multi buildpack that includes nodejs-grunt buildpack.

Running "imagemin:dist" (imagemin) task
Fatal error: Object #<DestroyableTransform> has no method 'apply'

 !     Push rejected, failed to compile Multipack app 

During the npm install to heroku, I see these pre-build messages related to first gifsicle and pngquant:


       > gifsicle@0.1.7 postinstall /tmp/build_61b89ee7-bb51-4c9e-b873-7a63f17bd3ce/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-gifsicle/node_modules/gifsicle
       > node index.js

       ⚠ pre-build test failed, compiling from source...

       stream.js:94
             throw er; // Unhandled stream error in pipe.
                   ^
       Error: invalid tar file
           at Extract.Parse._startEntry (/tmp/build_61b89ee7-bb51-4c9e-b873-7a63f17bd3ce/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-gifsicle/node_modules/gifsicle/node_modules/bin-build/node_modules/download/node_modules/decompress/node_modules/tar/lib/parse.js:145:13)
           at Extract.Parse._process (/tmp/build_61b89ee7-bb51-4c9e-b873-7a63f17bd3ce/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-gifsicle/node_modules/gifsicle/node_modules/bin-build/node_modules/download/node_modules/decompress/node_modules/tar/lib/parse.js:127:12)
           at BlockStream.<anonymous> (/tmp/build_61b89ee7-bb51-4c9e-b873-7a63f17bd3ce/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-gifsicle/node_modules/gifsicle/node_modules/bin-build/node_modules/download/node_modules/decompress/node_modules/tar/lib/parse.js:47:8)
           at BlockStream.EventEmitter.emit (events.js:95:17)
           at BlockStream._emitChunk (/tmp/build_61b89ee7-bb51-4c9e-b873-7a63f17bd3ce/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-gifsicle/node_modules/gifsicle/node_modules/bin-build/node_modules/download/node_modules/decompress/node_modules/tar/node_modules/block-stream/block-stream.js:145:10)
           at BlockStream.resume (/tmp/build_61b89ee7-bb51-4c9e-b873-7a63f17bd3ce/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-gifsicle/node_modules/gifsicle/node_modules/bin-build/node_modules/download/node_modules/decompress/node_modules/tar/node_modules/block-stream/block-stream.js:58:15)
           at Extract.Reader.resume (/tmp/build_61b89ee7-bb51-4c9e-b873-7a63f17bd3ce/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-gifsicle/node_modules/gifsicle/node_modules/bin-build/node_modules/download/node_modules/decompress/node_modules/tar/node_modules/fstream/lib/reader.js:255:34)
           at DirWriter.<anonymous> (/tmp/build_61b89ee7-bb51-4c9e-b873-7a63f17bd3ce/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-gifsicle/node_modules/gifsicle/node_modules/bin-build/node_modules/download/node_modules/decompress/node_modules/tar/lib/extract.js:57:8)
           at DirWriter.EventEmitter.emit (events.js:92:17)
           at /tmp/build_61b89ee7-bb51-4c9e-b873-7a63f17bd3ce/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-gifsicle/node_modules/gifsicle/node_modules/bin-build/node_modules/download/node_modules/decompress/node_modules/tar/node_modules/fstream/lib/dir-writer.js:39:8
       npm http GET https://registry.npmjs.org/minimist/0.0.8
       npm http 304 https://registry.npmjs.org/minimist/0.0.8
       npm http GET https://registry.npmjs.org/commander
       npm http 304 https://registry.npmjs.org/commander
       npm http GET https://registry.npmjs.org/commander/-/commander-1.1.1.tgz
       npm http 200 https://registry.npmjs.org/commander/-/commander-1.1.1.tgz
       npm http GET https://registry.npmjs.org/keypress
       npm http 200 https://registry.npmjs.org/keypress
       npm http GET https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz
       npm http 200 https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz

       > pngquant-bin@0.3.5 postinstall /tmp/build_61b89ee7-bb51-4c9e-b873-7a63f17bd3ce/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-pngquant/node_modules/pngquant-bin
       > node index.js

       ⚠ pre-build test failed, compiling from source...
       ✔ pngquant built successfully!
       npm WARN optional dep failed, continuing imagemin-gifsicle@0.1.1

       > optipng-bin@0.3.11 postinstall /tmp/build_61b89ee7-bb51-4c9e-b873-7a63f17bd3ce/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/optipng-bin
       > node index.js

       ✔ pre-build test passed successfully!

       > gifsicle@1.0.3 postinstall /tmp/build_61b89ee7-bb51-4c9e-b873-7a63f17bd3ce/node_modules/imagemin-gifsicle/node_modules/gifsicle
       > node lib/install.js

         downloading : https://raw.github.com/imagemin/gifsicle-bin/v1.0.3/vendor/linux/x64/gifsicle

       ✔ pre-build test passed successfully!
       grunt-contrib-imagemin@0.8.0 node_modules/grunt-contrib-imagemin
       ├── pretty-bytes@0.1.2
       ├── async@0.7.0
       ├── chalk@0.5.1 (escape-string-regexp@1.0.2, ansi-styles@1.1.0, supports-color@0.2.0, strip-ansi@0.3.0, has-ansi@0.1.0)
       └── imagemin@0.4.9 (stat-mode@0.2.0, ware@0.3.0, rimraf@2.2.8, image-type@0.1.4, nopt@3.0.1, tempfile@0.1.3, fs-extra@0.10.0, imagemin-jpegtran@0.1.0, imagemin-svgo@0.1.1, imagemin-pngquant@0.1.3, imagemin-optipng@0.1.0)

       imagemin-gifsicle@2.0.0 node_modules/imagemin-gifsicle
       ├── is-gif@1.0.0
       ├── through2@0.6.2 (xtend@4.0.0, readable-stream@1.0.32)
       └── gifsicle@1.0.3 (log-symbols@1.0.1, bin-build@1.0.1, bin-wrapper@1.0.5)
-----> Caching node_modules directory for future builds
-----> Cleaning up node-gyp and npm artifacts
-----> Building runtime environment
-----> Exporting config vars to environment

@codoshop
Copy link

codoshop commented Oct 4, 2014

On OS X 10.9.5, I'm also getting the error:

Warning: Running "imagemin:dist" (imagemin) task
Fatal error: Object #<DestroyableTransform> has no method 'apply'

I'm using grunt-contrib-imagemin v0.8.1 and imagemin-pngquant v2.0.0. Neither solutions from @RavenHursT or @paulbjensen have fixed it for me.

@guycalledseven
Copy link

I have exactly the same issue on Windows.

Did clean install and this:

npm install grunt-contrib-imagemin --save-dev
npm install imagemin-gifsicle --save-dev
npm install imagemin-jpegtran --save-dev
npm install imagemin-optipng --save-dev
npm install imagemin-pngquant --save-dev

grunt serve works (no more imagemin errors), but grunt (for deploy) fails with
Warning: Running "imagemin:dist" (imagemin) task
Fatal error: Object # has no method 'apply'

If I use --force there is no image.

@adamasantares
Copy link

I have same problem on ubuntu.

root@root:/project$ grunt compressimages
Running "imagemin:dist" (imagemin) task
Fatal error: Object #<DestroyableTransform> has no method 'apply'

All necessary modules were installed successfully...

@kevva
Copy link
Member

kevva commented Oct 15, 2014

If you install any imagemin-plugin manually it'll use the latest version which makes use of streams. grunt-contrib-imagemin hasn't been updated to work with streams yet but there's an open PR for it (#251). If gifsicle is failing, try npm install imagemin-gifsicle@1.0.0.

@franz-josef-kaiser
Copy link

Same error on Windows(7):

me@PC:/c/project/foobar [img*]$ grunt img
Running "imagemin:jpg" (imagemin) task
Fatal error: Object #<Object> has no method 'apply'

The grunt:imagemin task definition/config:

var mozjpeg   = require( 'imagemin-mozjpeg' );
// ...
grunt.initConfig( {
    // ...
    imagemin : {
        jpg : {
            options : {
                use : [ mozjpeg() ]
            },
            files : [ {
                expand:  true,
                cwd:     '<%= site.dev %>/<%= site.assets %>/<%= site.img.root %>/',
                src:     ['**/*.{png,jpg,gif}'],
                dest:    './cache'
            } ]
        }
    },
} );

Output from running grunt --verbose

me@PC:/c/project/foobar [img*]$ grunt img --verbose
Initializing
Command-line options: --verbose

Reading "Gruntfile.js" Gruntfile...OK

Registering Gruntfile tasks.

Reading package.json...OK
Parsing package.json...OK
Reading config/config.json...OK
Parsing config/config.json...OK
Initializing config...OK

Loading "Gruntfile.js" tasks...OK
+ css, img, js, json, php, templates, updatehooks

Running tasks: img

Running "img" task

Running "imagemin" task

Running "imagemin:jpg" (imagemin) task
Verifying property imagemin.jpg exists in config...OK
Files: dev/assets/img/gif/gif-interlaced_bril.gif -> cache/gif/gif-interlaced_bril.gif
Files: dev/assets/img/jpg/125H.jpg -> cache/jpg/125H.jpg
Files: dev/assets/img/jpg/131H.jpg -> cache/jpg/131H.jpg
Files: dev/assets/img/jpg/24_1_saatbau.jpg -> cache/jpg/24_1_saatbau.jpg
Files: dev/assets/img/jpg/24_2_saatbau.jpg -> cache/jpg/24_2_saatbau.jpg
Files: dev/assets/img/jpg/40_1_jugendservice.jpg -> cache/jpg/40_1_jugendservice.jpg
Files: dev/assets/img/jpg/40_2_jugendservice.jpg -> cache/jpg/40_2_jugendservice.jpg
Files: dev/assets/img/jpg/53_kraiburg.jpg -> cache/jpg/53_kraiburg.jpg
Files: dev/assets/img/jpg/sunrise-175970.jpg -> cache/jpg/sunrise-175970.jpg
Files: dev/assets/img/jpg/sunset-198875_1280.jpg -> cache/jpg/sunset-198875_1280.jpg
Files: dev/assets/img/png/png24-interlaced_bril.png -> cache/png/png24-interlaced_bril.png
Files: dev/assets/img/png/png24-interlaced_grote-ogen.png -> cache/png/png24-interlaced_grote-ogen.png
Files: dev/assets/img/png/png24-interlaced_oog.png -> cache/png/png24-interlaced_oog.png
Files: dev/assets/img/png/png24-interlaced_rood.png -> cache/png/png24-interlaced_rood.png
Files: dev/assets/img/png/png24-interlaced_skyline.png -> cache/png/png24-interlaced_skyline.png
Files: dev/assets/img/png/png24-interlaced_wolk.png -> cache/png/png24-interlaced_wolk.png
Files: dev/assets/img/png/png24_grote-ogen.png -> cache/png/png24_grote-ogen.png
Files: dev/assets/img/png/png24_oog.png -> cache/png/png24_oog.png
Files: dev/assets/img/png/png24_rood.png -> cache/png/png24_rood.png
Files: dev/assets/img/png/png24_skyline.png -> cache/png/png24_skyline.png
Files: dev/assets/img/png/png24_wolk.png -> cache/png/png24_wolk.png
Options: interlaced, optimizationLevel=3, progressive, use=[{"_readableState":{"highWaterMark":16,"buffer":[],"length":0,"pipes":null,"pipesCount":0,"flowing":false,"ended":fa
lse,"endEmitted":false,"reading":false,"calledRead":false,"sync":false,"needReadable":true,"emittedReadable":false,"readableListening":false,"objectMode":true,"defaultEncoding
":"utf8","ranOut":false,"awaitDrain":0,"readingMore":false,"decoder":null,"encoding":null},"readable":true,"domain":null,"_events":{},"_maxListeners":10,"_writableState":{"hig
hWaterMark":16,"objectMode":true,"needDrain":false,"ending":false,"ended":false,"finished":false,"decodeStrings":true,"defaultEncoding":"utf8","length":0,"writing":false,"sync
":true,"bufferProcessing":false,"writecb":null,"writelen":0,"buffer":[],"errorEmitted":false},"writable":true,"allowHalfOpen":true,"_transformState":{"needTransform":false,"tr
ansforming":false,"writecb":null,"writechunk":null},"_destroyed":false}]
Fatal error: Object #<Object> has no method 'apply'


Execution Time (2014-10-22 11:06:04 UTC)
loading tasks   58.1s  ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 65%
imagemin:jpg    31.1s  ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 35%
Total 1m 29.2s

Sadly there is exactly null info about where and why it failed. The setup is exactly as in the README.md file in this repository.

@kevva
Copy link
Member

kevva commented Oct 22, 2014

You're using an unsupported version of imagemin-mozjpeg (grunt-contrib-imagemin doesn't support the stream based plugins yet). Try this npm install imagemin-mozjpeg@1.

@franz-josef-kaiser
Copy link

Oh. Why that? And how do you know that? I haven't provided any information about what version I use. Btw, it's the following (package.json):

"imagemin-mozjpeg" : "~3.1.0",

@kevva
Copy link
Member

kevva commented Oct 22, 2014

I know that because of the last lines in your log (Fatal error: Object #<Object> has no method 'apply'). I'm the author of imagemin so these errors aren't directly unseen to me (unfortunately, lol).

@franz-josef-kaiser
Copy link

I got that you are the author, but didn't know that no method 'apply' translates to stream plugin used and unsupported.

Anyway, some additional info: The plugin and version I use is on of the plugins linked to from the README.md. They are marked as "imagemin plugins".

@kevva
Copy link
Member

kevva commented Oct 22, 2014

Yeah, they work just fine with imagemin. But grunt-contrib-imagemin hasn't updated the imagemin dependency to 2.0.0 yet (just got merged yesterday in 04b8c10) so it's making use of an older API.

@franz-josef-kaiser
Copy link

oh, man. If I'd only known earlier.. :/ thanks a lot.

@kevva
Copy link
Member

kevva commented Oct 22, 2014

Yeah, no problem! Keep an eye on other open/closed issues to see if other people have the same problem. It feels like I have answered this in a couple different tickets now :P.

@kevva
Copy link
Member

kevva commented Oct 23, 2014

This should be fixed in 0.9.0.

@kevva kevva closed this as completed Oct 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants