sindresorhus / gulp-imagemin

Minify PNG, JPEG, GIF and SVG images
MIT License
1.9k stars 157 forks source link

Using mozjpeg to compress pictures will result in errors! #338

Closed JohnApache closed 4 years ago

JohnApache commented 4 years ago
Message:
    spawn /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/node_modules/mozjpeg/vendor/cjpeg ENOENT
Details:
    errno: ENOENT
    code: ENOENT
    syscall: spawn /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/node_modules/mozjpeg/vendor/cjpeg
    path: /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/node_modules/mozjpeg/vendor/cjpeg
    spawnargs: 
    stdout: 
    stderr: 
    failed: true
    signal: null
    cmd: /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/node_modules/mozjpeg/vendor/cjpeg
    timedOut: false
    killed: false
    fileName: /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/src/images/20171219195409_ez4Vu.jpeg
    domainEmitter: [object Object]
    domainThrown: false

I try to use mozjpeg command directly,like this

npx mozjpeg --help

Exception will still be thrown.

spawn /Users/cuijianwei/WebstormProjects/testproject/gulp-demo/node_modules/mozjpeg/vendor/cjpeg ENOENT

When I reduce imagemin to 6.2.0,Imagemin 6.2.0 compress JPEG pictures with jpegtran, and there's no problem with jpegtran.

I hope this problem can be solved.

jmarshall9120 commented 3 years ago

@JohnApache - I'm experiencing this same issue. What was your final resolution? Would you mind sharing how its been working out over the last year?

carlosesierra commented 3 years ago

similar issue here :(

"gulp-imagemin": "^7.1.0",

gulp-imagemin: Couldn't load default plugin "gifsicle"

Message: spawn /Users/hello/Desktop/carlos.sierra/banners/beta/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor/cjpeg ENOENT Details: errno: -2 code: ENOENT syscall: spawn /Users/hello/Desktop/carlos/banners/beta/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor/cjpeg path: /Users/hello/Desktop/carlos/banners/beta/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor/cjpeg spawnargs: stdout: stderr: failed: true signal: null cmd: /Users/hello/Desktop/carlos/banners/beta/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor/cjpeg timedOut: false killed: false fileName: /Users/hello/Desktop/carlos/banners/beta/0001/src/items/300x600/img/bg.jpg domainEmitter: [object Object] domainThrown: false

tangkunyin commented 3 years ago

In my case, the problem occurred after I upgrade npm to latest version(7.10.0). At first, I run rm -rf node_modules && npm install but it does't work at all.....

Then I try to check the mozjpeg folder and I found there was no vender/cjpeg. So I try to install packages whith yarn install and at last it works

For more details: https://github.com/npm/cli/issues/1905 https://github.com/npm/cli/issues/3100

image

joson commented 3 years ago

I've resolved this problem by fixing the error while install gulp-imageimge. I reinstalled gulp-imageimge, and found that the mozjpeg had been installed but couldn't be compiled well. And then the installation passed through quickly, so that you might not take notice of the error message. The error message to me was a lib named 'nasm' was missing. I installed it on my Linux OS. Then it can be reinstalled well. npm version: 6.14

pm0u commented 1 year ago

This seems to be an error with npm >= 7, we were able to get past this with npm install -g npm@6 although really not sure why