image-lambda
image-lambda copied to clipboard
Cannot find module imagemin-pngquant
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?
Could you please send me your zip package? Your information is not enough to locate the issue.
Sure: slim-lambda.zip
Your config.json
file is wrong, you should write it as what documented in readme.
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 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).
I ended up writing my own lambda function, it's here if anyone is interested