Search code examples
javascriptnode.jspromiseimagemin

then is not a function


I'm running the following code in my node.js project. I've required "imagemin" and "imageminGifsicle". I've getting the following error

}).then(files => { ^ TypeError: imagemin(...).then is not a function

Do I have not used promises in my projects before. Do I need to include them to use .then ?

imagemin(['export/sample/out.gif'], 'export/sample/out2.gif', {
 plugins: [
  imageminGifsicle({optimizationLevel: 1})
 ]
}).then(files => {
  console.log(files);
  console.log("finished");
}).catch(err => {
  console.log("ERR:"+err);
  throw err;
});

Solution

  • .then is Promise related and imagemin added this only on 5.0.0.

    What version of it are you using?