5

I've been attempting to solve this for over half the day now.

I have an angularjs project that I use grunt to build.

Running my grunt command give me the following:

``` Running "concurrent:dist" (concurrent) task

Running "svgmin:dist" (svgmin) task
Total saved: 0 B

Done, without errors.


Execution Time (2014-09-23 21:53:55 UTC)
loading tasks   7ms  ▇▇▇▇▇▇ 11%
svgmin:dist    58ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 89%
Total 65ms
    Warning: Running "imagemin:dist" (imagemin) task
Fatal error: Object #<DestroyableTransform> has no method 'apply'


Execution Time (2014-09-23 21:53:55 UTC)
imagemin:dist  868ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 99%
Total 876ms Use --force to continue.

    Aborted due to warnings.

```

Here's my imagemin task in my GruntFile.js:

imagemin: { dist: { files: [ { expand: true, cwd: '<%= yeoman.app %>/images', src: '{,*/}*.{png,jpg,jpeg,gif}', dest: '<%= yeoman.dist %>/images' } ] } }

I can't find anything on the interwebs that helps me. I did find this open issue, but no one has responded as of yet: https://github.com/gruntjs/grunt-contrib-imagemin/issues/254

Thanks.

RavenHursT
  • 2,336
  • 1
  • 25
  • 46

4 Answers4

6

Apparently, png compression requires the libpng-dev library and I needed to install that on my build server using:

sudo apt-get install libpng-dev

I also updated my package.json to use the latest grunt-contrib-imagemin ("^0.8.0")

Running npm install and grunt now work w/o errors.

RavenHursT
  • 2,336
  • 1
  • 25
  • 46
2

In short, I am using Fedora and my problem was solved by:

(sudo) yum install optipng

Here is the long answer.

This problem was not obvious because the error message does not tell much. It actually means one or more of the four dependencies was(were) missing:

gifsicle — Compress GIF images
jpegtran — Compress JPEG images
optipng — Compress PNG images
svgo — Compress SVG images

And those binaries are OS dependent.

The problem solving process is:

  1. run the installation again to see what are not installed: npm install grunt-contrib-imagemin
  2. google the failing component and see how that can be installed in your OS. Install all missing ones. (Well, if I should repeat step 1, I have gotten the same failure message, so for me it didn't help)
  3. then try run imagemin task again. Fingers crossed.
chfw
  • 4,502
  • 2
  • 29
  • 32
2

imagemin error through using grunt serve:dist-mode.

Try the following instead.

  1. npm uninstall
  2. rm -rf node_modules
  3. npm cache clean
  4. npm install
kaiser
  • 21,817
  • 17
  • 90
  • 110
vinodh
  • 2,114
  • 1
  • 12
  • 17
1

As the author/@kevva of imagemin commented on a GitHub issue on grunt-contrib-imagemin, the problem is that the PR to update mozjpeg and other dependencies to the current version isn't yet in.

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

...

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.

Community
  • 1
  • 1
kaiser
  • 21,817
  • 17
  • 90
  • 110