I'm trying to get a lambda layer of "sharp". Foll...
# help
p
I'm trying to get a lambda layer of "sharp". Following this example: https://github.com/serverless-stack/serverless-stack/tree/master/examples/bucket-image-resize It seems to be missing the "layers/sharp" folder... what goes in there? The docs say to
Copy code
Unzip the packaged layer to this directory.
Does that mean copy whats in node_modules?
t
Do you particularly want a layer? Or do you just want to get sharp working
p
I just want sharp working 😆
t
if the latter you can just add to your function props
bundle.nodeModules: ["sharp"]
cc @Jay seems like maybe this example is missing something
j
Hey @Patrick Young here’s the tutorial that goes with this: https://serverless-stack.com/examples/how-to-automatically-resize-images-with-serverless.html
Let me know if that helps?
p
Ah cool. Thanks @Jay. Yeah that step makes more sense now:
Copy code
Then head over to this repo and download the latest sharp-lambda-layer.zip from the releases — <https://github.com/Umkus/lambda-layer-sharp/releases>

Unzip that into the layers/sharp directory that we just created. Make sure that the path looks something like layers/sharp/nodejs/node_modules.
I'm going to just try to get this working and then try to get layers working. I will let you know if I run into anything or if the tutorial can be tweaked.
Hitting this:
Copy code
Something went wrong installing the "sharp" module

Cannot find module '../build/Release/sharp-linux-x64.node'
So guessing I need this in the deploy script:
Copy code
"npm install --platform=linux --arch=x64 sharp"
or... I saw a bunch of people had another script before the deploy to set this. Since I'm running this with Rushjs I'm not 100% sure how to do this... darn monorepo
Plugin away
So I got layers working with sharp 🎉 . So thank you! I'm guessing for best practices I shouldn't be downloading a zip folder and instead should be building it off a package.json that does something similar to that library?
Or could I just have the layer look into the node_modules folder vs the copy pasta zip method?
j
I think this depends on the layer. For things that are machine dependent, I think the zip makes more sense.