vercel: node-canvas runtime error
Hi 👋 , I’m having a runtime error with my app that uses node-canvas@2.6.0. It doesn’t uses it directly, but through the package text2png@2.3.0. Here is the error I got
2019-12-23T05:47:22.676Z undefined ERROR Error: libuuid.so.1: cannot open shared object file: No such file or directory
at Object.Module._extensions..node (internal/modules/cjs/loader.js:807:18)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/var/task/node_modules/canvas/lib/bindings.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
As far I know, right now AWS Lambda functions doesn’t include the necessary libraries to work correctly with this package. This is describe in node-canvas#1448 and now I’m wondering if there is a work around in now to this issue.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 3
- Comments: 56 (4 by maintainers)
Commits related to this issue
- add build step for node-canvas see https://github.com/vercel/vercel/issues/3460 — committed to sgratzl/yacobo by sgratzl 4 years ago
- :bug: Fix node-canvas lambda runtime error I was getting 500s on the lambda with the error 'cannot open shared object file: No such file or directory', it looks like it's something to do with node-ca... — committed to pouretrebelle/jigsaws by pouretrebelle 3 years ago
- :bug: Fix node-canvas lambda runtime error I was getting 500s on the lambda with the error 'cannot open shared object file: No such file or directory', it looks like it's something to do with node-ca... — committed to pouretrebelle/jigsaws by pouretrebelle 3 years ago
- :bug: Fix node-canvas lambda runtime error I was getting 500s on the lambda with the error 'cannot open shared object file: No such file or directory', it looks like it's something to do with node-ca... — committed to pouretrebelle/jigsaws by pouretrebelle 3 years ago
- :bug: Fix node-canvas lambda runtime error I was getting 500s on the lambda with the error 'cannot open shared object file: No such file or directory', it looks like it's something to do with node-ca... — committed to pouretrebelle/jigsaws by pouretrebelle 3 years ago
- :bug: Fix node-canvas lambda runtime error I was getting 500s on the lambda with the error 'cannot open shared object file: No such file or directory', it looks like it's something to do with node-ca... — committed to pouretrebelle/jigsaws by pouretrebelle 3 years ago
- :bug: Fix node-canvas lambda runtime error I was getting 500s on the lambda with the error 'cannot open shared object file: No such file or directory', it looks like it's something to do with node-ca... — committed to pouretrebelle/jigsaws by pouretrebelle 3 years ago
- :bug: Fix node-canvas lambda runtime error I was getting 500s on the lambda with the error 'cannot open shared object file: No such file or directory', it looks like it's something to do with node-ca... — committed to pouretrebelle/jigsaws by pouretrebelle 3 years ago
- :bug: Fix node-canvas lambda runtime error I was getting 500s on the lambda with the error 'cannot open shared object file: No such file or directory', it looks like it's something to do with node-ca... — committed to pouretrebelle/jigsaws by pouretrebelle 3 years ago
- :bug: Fix node-canvas lambda runtime error I was getting 500s on the lambda with the error 'cannot open shared object file: No such file or directory', it looks like it's something to do with node-ca... — committed to pouretrebelle/jigsaws by pouretrebelle 3 years ago
- :wrench: chore: 调整构建脚本,修正 canvas 构建问题 ref: https://github.com/vercel/vercel/issues/3460#issuecomment-905415509 — committed to arvinxx/components by arvinxx 2 years ago
- :bookmark: chore(release): @arvinxu/layout-kit@1.1.0 [skip ci] # [1.1.0](https://github.com/arvinxx/components/compare/@arvinxu/layout-kit@1.0.0...@arvinxu/layout-kit@1.1.0) (2022-02-02) ### ♻ 重构 *... — committed to arvinxx/components by semantic-release-bot 2 years ago
- :bookmark: chore(release): @arvinxu/sortable-list@1.0.0 [skip ci] # 1.0.0 (2022-02-02) ### ♻ 重构 * 优化 out 的节点逻辑 ([7a3c171](https://github.com/arvinxx/components/commit/7a3c171)) * 优化代码 ([4e28bd6](ht... — committed to arvinxx/components by semantic-release-bot 2 years ago
- More bits to address issue 1448 https://github.com/vercel/vercel/issues/3460#issuecomment-913891317 — committed to andy-shearer/devbears by andy-shearer 2 years ago
- chore: remove canvas test (#388) This fixes an issue when a contributor runs `npm install` using Apple Silicon which would fail since there is no precompiled arm64 binary to download for `canvas`. ... — committed to vercel/nft by styfle 5 months ago
As an alternative to
node-canvas, try@napi-rs/canvaswhich has a lot of the same features.Thanks to @Brooooooklyn
Right you are @likeablob , thanks a lot!
2 noteworthy things:
yum install libuuid-devel libmount-devel && cp /lib64/{libuuid,libmount,libblkid}.so.1 node_modules/canvas/build/Release/worked while thecp canvas_lib64/*so.1 node_modules/canvas/build/Release/method (having downloaded and unzipped the files) did not work (for me).npm run buildfrom within mynow-buildnpm script.If it helps anyone, I ended up with this in my package.json:
As an ugly workaround, I ended up using the following
now-build.BTW, Thanks @jwerre !
Checkout the demo of
@napi-rs/canvason Vercel, without any configuration: https://github.com/Brooooooklyn/vercel-canvas/blob/main/api/canvas.jshttps://vercel.skia.rs/api/canvas
I get this after everything:
ERROR Error: /lib64/libz.so.1: version `ZLIB_1.2.9’ not found (required by /var/task/node_modules/canvas/build/Release/libpng16.so.16)
I tried a number of possible combinations of solutions suggested between three different threads. This is the only one that has worked for me. Thank you @TixieBorg
switched to node 12 runtime and it just started working \o/ Still have the weird yum install hack in my package.json, though, looks like:
currently using
"vercel-build": "yum install libuuid-devel libmount-devel && cp /lib64/{libuuid,libmount,libblkid}.so.1 node_modules/canvas/build/Release/ && next build"in mypackage.jsonand
yarn install && yarn run vercel-buildin my vercel install scriptBut this only works with Node 16, and does not work with Node 18
Any idea how to get it to work with Node 18?
Switched to just rendering on the frontend and using urlbox.io 😃
On Tue, Dec 14, 2021 at 3:47 PM Steven @.***> wrote:
@rzinurov still get the same error using
canvas@2.6.1The easiest way out that I’ve found was to downgrade to
canvas@2.6.1. This version of node-canvas does not require newer versions of libuuid-devel, libmount-devel and zlib, and it works in Vercel Node14 runtime without any extra dependencies. In case if you need to use node-canvas 2.7.0+, you’d most likely have to build zlib-1.2.9 from sources and copy libs from/lib64/tonode_modules/canvas/build/Release/in the vercel-build script, as it was suggested above, well at least until zlib-1.2.9 becomes available through yum.@elmariachi111 Wow thanks so much, spent 2 days on this error, downgrading to node 12.x was the only working solution… Would love if someone finds a way to fix it on Node 14 too…
I found a solution through this issue: https://github.com/Automattic/node-canvas/issues/1779#issuecomment-896125623.
Adding this to top of your next.config.js and deploy should work!
Actually this solution only works in client rendering, if you’re trying to use SSR this solution won’t work for you.
I have a working config. I hope the explanations will help. Don’t hesitate to ask for precision on stuff I’ve may have forgot to share 😃
My setup include:
LD_LIBRARY_PATH/LD_PRELOADenv variablesMy use case was to create a social card for Open Graph, so i have a /api/social-image.png.js file with this as default function:
createImagebeing the function who calls node-canvasJust fought this for the better part of 4 hours. There seems to be a lot of advice across a few different GitHub issues, none of which worked for me on their own. First missing libraries(
libuuid), then a wrong/missing version ofzlib(ZLIB_1.2.9 not found (required by /opt/nodejs/node_modules/canvas/build/Release/libpng16.so.16)).Here’s what finally ended up working for me:
Node: 14.x canvas: ^2.8.0
setup.shfile to the project :package.jsonwith avercel-buildscript to handle installing the missing packages:Things that didn’t work for me
vercel-buildcommand, including zlibLD_LIBRARY_PATHorLD_PRELOADenvironment variables@shawninder this works for me:
I’ve solved this issue in a bit more complicated way:
install.shis checking that target system is correct to run the command@diogoviannaaraujo fixed in https://github.com/Brooooooklyn/canvas/releases/tag/v0.1.23
@chrisco255 When I try this I get
cp: cannot stat ‘canvas_lib64/*’: No such file or directoryI ended up having to manually generate my
libz.so.1file fromzlib-1.2.9, because yum would only install v1.2.7+(some amazon suffix) fromvercel-build. I also went ahead and manually added all the other*.sofiles that canvas needs (ielibblkid.so.1, etc.) in a arbitrary root folder. Then I runvercel-buildto copy the files from that root folder intobuild/Release.So mine ended up looking like this:
and the files I added to
canvas_lib64were:That seems to have solved it for me.
Added --skip-broken to the yum command to make it work, but really… Sounds weird
some of the dependencies is now broken,
Error: Package: glibc-2.26-48.amzn2.i686 (amzn2-core)
Thank you so much @mschonvogel it worked!
I guess it was the
path.resolvethat I needed. Perhaps when I had tried it earlier something else was wrong?Sorry for highjacking the thread everyone, but this really did help!
Glad I could help 😃
Unfortunately, this wasn’t the end of my problems with node-canvas in the context of a Vercel deployment. Now that things are building, I’m finding I can’t load any fonts… Perhaps someone here would be able to give me a hand via this stackoverflow post: https://stackoverflow.com/questions/60103921/node-canvas-registerfont-cant-find-font-file-once-deployed-works-locally