Yeaoman Grunt imagemin Fatal error: Cannot read property 'contents' of undefined

Yeaoman Grunt imagemin Fatal error: Cannot read property 'contents' of undefined

即使使用干净的 Yeoman angular 构建,我也会在 运行 grunt build 时继续获取:yo angular whatever.

Warning: Running "imagemin:dist" (imagemin) task

Fatal error: Cannot read property 'contents' of undefined

我不得不降级 imagemin,现在一切正常。

npm cache clean && npm install grunt-contrib-imagemin@0.9.1

只需更新您的 grunt-contrib-imagemin 版本即可。

例如:"grunt-contrib-imagemin": "^0.9.2"

"grunt-contrib-imagemin": "^1.0.0"

对我有用。

我在 Gruntfile.js 中更改了这一行:

src: '{,*/}*.{png,jpg,jpeg,gif}',

到这一行:

src: '[*/*.{png,jpg,jpeg,gif,svg}]'