mozjpeg is a production-quality JPEG encoder that improves compression while maintaining compatibility with the vast majority of deployed decoders
You probably want imagemin-mozjpeg
instead.
In order to prevent downloading difficultly in China area, I decided to change the code and push bin files to npm so as to use it directly.
$ npm install --save mozjpeg
const {execFile} = require('child_process');
const mozjpeg = require('mozjpeg');
execFile(mozjpeg, ['-outfile', 'output.jpg', 'input.jpg'], err => {
console.log('Image minified!');
});
$ npm install --global mozjpeg
$ mozjpeg --help
MIT © Imagemin