imagemin / imagemin-mozjpeg

Imagemin plugin for mozjpeg
MIT License
251 stars 57 forks source link

Getting an error on Win 10 #58

Closed jaruba closed 3 years ago

jaruba commented 3 years ago

I've been trying to use this on Win 10.

My code:

const imagemin = require('imagemin')
const imageminMozjpeg = require('imagemin-mozjpeg')

async function init(from, dest) {
    try {
        await imagemin([from], {
            destination: dest,
            plugins: [ imageminMozjpeg({ quality: 80 }) ]
        })
    } catch(e) { console.error(e) }
}

init('media/test.jpg', 'media/optimized')

And I get this error:

{ TypeError: Command failed: I:\media-test\node_modules\mozjpeg\vendor\cjpeg.exe -quality 80
timedPromise.finally is not a function
    at setExitHandler (I:\media-test\node_modules\execa\lib\kill.js:102:29)
    at execa (I:\media-test\node_modules\execa\index.js:100:22)
    at I:\media-test\node_modules\imagemin-mozjpeg\index.js:109:25
    at I:\media-test\node_modules\p-pipe\index.js:12:25
    at handleFile (I:\media-test\node_modules\imagemin\index.js:21:54)
    at <anonymous>
  originalMessage: 'timedPromise.finally is not a function',
  shortMessage: 'Command failed: I:\\media-test\\node_modules\\mozjpeg\\vendor\\cjpeg.exe -quality 80\ntimedPromise.finally is not a function',
  command: 'I:\\media-test\\node_modules\\mozjpeg\\vendor\\cjpeg.exe -quality 80',
  exitCode: undefined,
  signal: undefined,
  signalDescription: undefined,
  stdout: <Buffer >,
  stderr: <Buffer >,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false }

I checked and I:\media-test\node_modules\mozjpeg\vendor\cjpeg.exe does exist, i tried to run this executable with no arguments and it worked to run it (although gave no output). I know the path to the image and the destination folder are also correct as the same code does work when I try it with imagemin-jpegtrans.

Any help would be appreciated.

jaruba commented 3 years ago

timedPromise.finally is not a function could this be a node.js version incompatibility? what node version is required for this module?

jaruba commented 3 years ago

https://github.com/imagemin/imagemin-mozjpeg/commit/96e94271cea3ac69d8d67b69356994750e240a52

ok, it needs node.js v10+