我在我的node.js项目中运行以下代码。我需要“ imagemin”和“ imageminGifsicle”。我收到以下错误


  })。then(files => {
     ^
  TypeError:imagemin(...)。then不是一个函数


我以前没有在项目中使用诺言吗?我需要包括它们才能使用.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;
});

最佳答案

.then与Promise有关,而imagemin added this only on 5.0.0

您使用的是哪个版本?

关于javascript - 那不是功能,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40059781/

10-09 14:27