node-canvas-lambda
node-canvas-lambda copied to clipboard
More libraries required for Chart.js
Hey there, I made a fork where the lib64 layer includes a few more libraries:
libuuid.so.1
libpixman-1.so.0
libpangoft2-1.0.so.0
libjpeg.so.62
libmount.so.1
libpango-1.0.so.0
libpangocairo-1.0.so.0
libblkid.so.1
libcairo.so.2
libfreetype.so.6
libpng.so.16
These were necessary to get Chart.js working on AWS Lambda.
I got the list from here: https://github.com/Automattic/node-canvas/issues/680#issuecomment-364627155
Fork: https://github.com/nabilfreeman/node-canvas-lambda
Actually it didn't work, needed libpng16 which wasn't even on Amazon Linux 2 AMI.
I gave up and am using quickchart.io
@nabilfreeman This should work with Chart.js. I recommend using https://github.com/SeanSobey/ChartjsNodeCanvas
@nabilfreeman dude! thanks for the canvas-lib64-layer.zip, you've saved my sanity!
🙌🏻
@jwerre @nabilfreeman any of you guys tried running/getting a Node 14.x lambda layer? I'm updating our stack at the moment and charts are coming back blank - not sure what I'm doing wrong if anything.
@gligorkot Did you manage to solve for Node 14?
@bretto36 I did manage to, but I never finalised my solution nor deployed it - it's on my list to get back to it over the next few months, but other things are taking priority at the moment. Please share your solution if you do manage to get it working 🙏
So, I made it work with Node 14, by trying out some solutions from this thread here https://github.com/Automattic/node-canvas/issues/1779
What worked for me was exposing an ENV variable for the lambda runtime that's using the layer.
LD_LIBRARY_PATH: '/var/task/node_modules/canvas/build/Release'
Hey all, I managed to get a Node 16.x lambda layer going using one of the forks from @igara and working on top of it here https://github.com/gligorkot/node-canvas-lambda
I then used the ENV variable from @AltanS above in my Lambda and voilà it all works on the latest AWS Lambda Node 16.x runtime.
Hope this helps someone if they stumble upon it.
Now I can rest for another 2 years before needing to update these again 🙂
Thanks for the help @gligorkot. I'll dig into this today and see if I can't get it fixed up. Version 2 is underway!
@gligorkot can you do me a favor and create a merge request into the development branch so I can take a look at it?
@jwerre good work updating the main repo to the latest AWS Node.js supported version. I think this issue can now be closed, right?
The only thing I don't see in the Readme is instructions about adding an ENV Var LD_LIBRARY_PATH: '/var/task/node_modules/canvas/build/Release' as @AltanS mentioned above. Not sure if that's required with your solution now @jwerre?
This is why I love Open Source! :)
@gligorkot. Yes, these issues should be resolved. You do not need to set the LD_LIBRARY_PATH since one of the paths here is opt/lib. This is the location of your layers if they are attached your function correctly. If you're continuing to have trouble check which architecture you're using: AMD or x86. If you're using x86 check out the x86-64 branch and publish from there.
git checkout x86-64
make build
make test
make publish