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

"Cannot read property 'contents' of undefined" - after npm & imagemin update #73

Closed
mobidev111 opened this issue Nov 11, 2014 · 6 comments

Comments

@mobidev111
Copy link

npm version 2.1.7

package.json

    "devDependencies": {
        "gulp-imagemin": "^1.0.1",
        "imagemin-pngcrush": "^1.0.0",
        ...
    },

After a fresh npm install the following error appears. This as well happens with "gulp-imagemin": "^1.2.1".
The same code worked with an earlier npm version.

/Users/Test/testproject/node_modules/imagemin-pngcrush/index.js:18
        if (!isPng(file.contents)) {
                       ^
TypeError: Cannot read property 'contents' of undefined
    at /Users/Test/testproject/node_modules/imagemin-pngcrush/index.js:18:18
    at Imagemin.use (/Users/Test/testproject/node_modules/gulp-imagemin/node_modules/imagemin/index.js:64:51)
    at Array.forEach (native)
    at DestroyableTransform.through.obj.percent (/Users/Test/testproject/node_modules/gulp-imagemin/index.js:47:16)
    at DestroyableTransform._transform (/Users/Test/testproject/node_modules/gulp-imagemin/node_modules/through2-concurrent/through2-concurrent.js:29:15)
    at DestroyableTransform.Transform._read (/Users/Test/testproject/node_modules/gulp-imagemin/node_modules/through2-concurrent/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (/Users/Test/testproject/node_modules/gulp-imagemin/node_modules/through2-concurrent/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/Users/Test/testproject/node_modules/gulp-imagemin/node_modules/through2-concurrent/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer (/Users/Test/testproject/node_modules/gulp-imagemin/node_modules/through2-concurrent/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
    at DestroyableTransform.Writable.write (/Users/Test/testproject/node_modules/gulp-imagemin/node_modules/through2-concurrent/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
@kevva
Copy link
Contributor

kevva commented Nov 12, 2014

Seems like it's something wrong with your gulpfile. You're essentially piping "nothing" to gulp-imagemin and therefore it can't read the contents of your file. Can you paste it here or in a gist?

@kevva
Copy link
Contributor

kevva commented Nov 17, 2014

Well, going to close this since it's not an issue with imagemin but rather something in your gulp pipeline.

@kevva kevva closed this as completed Nov 17, 2014
@drewnoakes
Copy link

I'm seeing this issue pop up on OSX for a gulpfile that works on Linux. There's no difference to the contents of the pipe in either case.

@drewnoakes
Copy link

See also gruntjs/grunt-contrib-imagemin#208.

@blindlybright
Copy link

I found a difference between previous gulp task on image optimization & example shown on https://www.npmjs.com/package/gulp-imagemin. Now it's useful to use imagemin-pngquant plugin instead of imagemin-pngcrush.

@raydelto
Copy link

update the package.json file and modify your grunt-contrib-imagemin to "grunt-contrib-imagemin": "^1.0.0",

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

5 participants