grunt-contrib-imagemin: Can't make it work anymore

Starting from yo + webapp generator 0.4.9 I can’t make it work anymore. The first error I can see is this:

> optipng-bin@0.3.8 postinstall /Users/mattia.asti/Web/TechHub/test_yo/node_modules/grunt-contrib-imagemin/node_modules/image-min/node_modules/optipng-bin
> node index.js


module.js:340
    throw err;
          ^
Error: Cannot find module 'lodash'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Users/mattia.asti/Web/TechHub/test_yo/node_modules/grunt-contrib-imagemin/node_modules/image-min/node_modules/map-key/index.js:3:12)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
npm WARN optional dep failed, continuing optipng-bin@0.3.8

The first time I run grunt build I receive this error:

Warning: Running "imagemin:dist" (imagemin) task
    Warning: Cannot find module 'optipng-bin' Use --force to continue.
    
    Aborted due to warnings.

Then I try to install it with npm install --save-dev optipng-bin it the installation process is fine.

Then I try to do grunt buildbut it’s failing again, if I run grunt imagemin -verbose this is the output:

Running "imagemin:dist" (imagemin) task
Verifying property imagemin.dist exists in config...OK
Files: ... -> ...
Options: optimizationLevel=7, progressive
Warning: Bad argument Use --force to continue.

I’m going crazy I don’t know actually how to solve this, any help it’s really appreciated.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

Just tried npm cache clean && npm install gruntjs/grunt-contrib-imagemin and looks like it’s working again.

Still I can’t explain what happened

This right, this problem cause me crazy.I try to start the new project, but this is also fail.Then try npm cache clean && npm install gruntjs/grunt-contrib-imagemin this work, don’t know why, waste a day.