image-lambda icon indicating copy to clipboard operation
image-lambda copied to clipboard

Cannot find module imagemin-pngquant

Open dariospadoni opened this issue 8 years ago • 6 comments

Hello I built the script with Vagrant, uploaded the zip file to S3 but I get this error when I test the function:

  "errorMessage": "Cannot find module 'imagemin-pngquant'",
  "errorType": "Error",
  "stackTrace": [
    "Object.<anonymous> (/var/task/lib/ImageProcessor.js:10:26)",
    "Module._compile (module.js:409:26)",
    "Object.Module._extensions..js (module.js:416:10)",
    "Module.load (module.js:343:32)",
    "Function.Module._load (module.js:300:12)",
    "Module.require (module.js:353:17)"
  ]
}```

I can see the imagemin-pngquant package inside the zip file...any idea?

dariospadoni avatar Nov 13 '16 14:11 dariospadoni

Could you please send me your zip package? Your information is not enough to locate the issue.

leonfancy avatar Nov 13 '16 14:11 leonfancy

Sure: slim-lambda.zip

dariospadoni avatar Nov 13 '16 15:11 dariospadoni

Your config.json file is wrong, you should write it as what documented in readme.

leonfancy avatar Nov 13 '16 16:11 leonfancy

Ah I see. So to semplify, I'm using now the following configuration

{
  "resizes": [
    {
      "width": 1200,
      "sourceDir": "./",
      "targetBucket": "amavido-dev",
      "targetDir": "optimized/hero",
      "ACL": "public-read"
    }
  ]
}

and I still get the same error. Are all the parameters required? For instance if I omit "sourceDir" and "targetBucket", is the function using the current bucket and folder of the uploaded image? (I also tried with "sourceDir": "" but same error again.

dariospadoni avatar Nov 13 '16 18:11 dariospadoni

@dariospadoni sorry I can't figure out why you're getting that error. However, I've now got a patch in that means you can omit the targetBucket (and if you do it will default to the same bucket as the original). I will look at doing a patch for omission of sourceDir. Note that you can't use the resize options {%}{@}{!}{<}{>}{^} yet, but I have a branch for that that I will submit as a pull request after I finish documenting it and merging the other pull request into my options branch if/when approved—I am not submitting patches all at once as otherwise it creates a bunch of merge conflicts (so I am saving the resolution work for myself).

matthewberryman avatar Dec 21 '16 05:12 matthewberryman

I ended up writing my own lambda function, it's here if anyone is interested

dariospadoni avatar Dec 21 '16 11:12 dariospadoni