WordPress-Starter-Theme icon indicating copy to clipboard operation
WordPress-Starter-Theme copied to clipboard

Grunt imagemin error - "Cannot read property 'contents' of undefined"

Open viktorstrate opened this issue 8 years ago • 3 comments

When I run grunt, it fails at imagemin:dist. I haven't modified any code in any ways. I'm running Windows 10, with node version 6.9.1 and npm version 3.10.8.

Expected behavior

Execute the imagemin:dist without errors

Actual behavior

Returned error Fatal error: Cannot read property 'contents' of undefined

Console log

$ grunt
Running "sass:dist" (sass) task

Running "autoprefixer:files" (autoprefixer) task
>> 2 autoprefixed stylesheets created.
>> 2 sourcemaps created.

Running "cssmin:minify" (cssmin) task
>> 2 files created. 23.21 kB → 7.5 kB

Running "uglify:plugins" (uglify) task
>> 1 sourcemap created.
>> 1 file created.

Running "uglify:main" (uglify) task
>> 1 sourcemap created.
>> 1 file created.

Running "imagemin:dist" (imagemin) task
Fatal error: Cannot read property 'contents' of undefined

viktorstrate avatar Nov 28 '16 20:11 viktorstrate

I haven't taken a look at this code in quite a while. I'm guessing that the packages and API's have changed. Try upgrading the package versions and see if that changes anything.

mattbanks avatar Nov 29 '16 01:11 mattbanks

https://github.com/gruntjs/grunt-contrib-imagemin/issues/330#issuecomment-196789102 helped me resolve this issue. Instead of adding ^1.0.0, I added ~1.0.0 though.

KulaGeoff avatar Dec 14 '16 06:12 KulaGeoff

Update package.json in #27

czuli avatar Oct 07 '19 11:10 czuli