Node-canvas error || libuuid.so.1: cannot open shared object file: No such file or directory

Hey there, @citylights :wave:

Thanks for chiming in and sharing that method two from your post worked! This will definitely be beneficial for future Forums members. :netliconfetti:

1 Like

So close to getting this figured out using all the help here so far but I hit a snag with this error:

The module '/var/task/node_modules/canvas/build/Release/canvas.node'\nwas compiled against a different Node.js version using\nNODE_MODULE_VERSION 93. This version of Node.js requires\nNODE_MODULE_VERSION 72. Please try re-compiling or re-installing\nthe module (for instance, using `npm rebuild` or `npm install`).","trace":["Error: The module '/var/task/node_modules/canvas/build/Release/canvas.node'","was compiled against a different Node.js version using","NODE_MODULE_VERSION 93.

I feel it should be relatively easy compared to the other errors I’ve been able to overcome and perhaps it requires setting a specific NPM_VERSION environment variable. Unfortunately, that didn’t do it.
My netlify.toml contains:

[build]
  publish = "public"
  command = "npm rebuild && cp ./libx86/* node_modules/canvas/build/Release && npm run debug"

so I’m lost on it still asking me to do a rebuild.

I also included libz.so.1 and libpng16.so in my libx86 folder, not sure how important that is. Still no luck yet :stuck_out_tongue:

Fixed this by downgrading from node v16 to v14 . A friend that used to work with Netlify made me aware that Functions does not support versions over 14 for now

Hello. Can we get eyes on this issue again?

canvas continues to crash with
“Error - libuuid.so.1: cannot open shared object file: No such file or directory”

I’ve tried everything here and this solution no longer works.

First of all. Xenial is no longer supported by multipass. If you want to try to make xenial builds than you’ll need to use docker.

Second. the so files were located in /lib/aarch64-linux-gnu/

I’ve tried both xenial and focal versions. Tried various node versions. And built all the so and copied them to the release folder and I’m still getting an error

Hey @vinh-perfectstorm,

We’ve replied in the helpdesk. Let us know if you want to continue the discussion here.

Are there any alternate methods or newer solutions? I’ve also hit my head on this and the fixes listed upstream are rather a bit over my head. Just need basic canvas support for a few simple tasks I created an on-demand builder to handle, all of which worked just fine locally with ntl.

Hey @stuntbox,

Here’s what we had sent in the helpdesk to the above request:

Sorry to see you’re struggling with that error. However, it seems that, that library is not designed to play well with AWS Lambda. I can see (in the linked GitHub issue), and everyone is trying various hacks to get it working for their project: Error: /lib64/libz.so.1: version `ZLIB_1.2.9' not found (required by /opt/nodejs/node_modules/canvas/build/Release/libpng16.so.16) · Issue #1779 · Automattic/node-canvas · GitHub.

Maybe one of that works for you. We don’t have any additional suggestions to offer, unfortunately.

1 Like

Much appreciated. Will keep experimenting and monitoring this thread.

omg i finally got it working.

long time coming. i actually used this thread back in ~may '21 to get this to work by using the brilliant tip from @devrel-team (ty!). However after having our builds frozen until we updated our target version of ubuntu it all broke again. Here’s what I needed to do to fix it again as pieced together from this thread (esp @citylights ty!) and the infamous Error: /lib64/libz.so.1: version `ZLIB_1.2.9' not found (required by /opt/nodejs/node_modules/canvas/build/Release/libpng16.so.16) · Issue #1779 · Automattic/node-canvas · GitHub.

  • use build image Focal 20.04
  • use https://github.com/Automattic/node-canvas with v2.11.0
  • add the following environment variables to netlify deploy settings (not to the .env file)
    • LD_LIBRARY_PATH to /var/task/node_modules/canvas/build/Release
  • Ensure the version of node is 16.19.1 by adding a .nvmrc file to the project root containing that version

Here’s a link to a working repo: GitHub - okwme/serverless-canvas: example configuration of serverless function using node-canvas with example renders here and here.

It also includes the files built in libx86 as @devrel-team originally suggested but don’t seem necessary anymore with the preceding configuration.

1 Like

thanks @okwme ! This worked for me.

I didn’t have to worry about the build image:

* use build image Focal 20.04

You’re right, Node 18 didn’t work. I had to add the env var, the .nvmrc file, and downgrade the Node version from 16 in the dashboard:

thanks for sharing this with the community.