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

I want to use the Netlify Functions to create dynamic images with node-canvas. The function can be accessed with a rewrite/redirect I implemented which would make the URL look like this: “https://plotzes-test.netlify.app/img/stats/USERNAME.png”.

If I use netlify dev from the Netlify CLI on my local machine and I go to “http://localhost:8888/img/stats/plotzes.png” for example then it fully works and I’ll get an image like this:

Example image generated with node-canvas

If I upload my site directory to Netlify then it will build perfectly fine, but when I try to run the function I get this error:

Error

{"errorType":"Error","errorMessage":"libuuid.so.1: cannot open shared object file: No such file or directory","trace":["Error: libuuid.so.1: cannot open shared object file: No such file or directory"," at Object.Module._extensions..node (internal/modules/cjs/loader.js:1065:18)"," at Module.load (internal/modules/cjs/loader.js:879:32)"," at Function.Module._load (internal/modules/cjs/loader.js:724:14)"," at Module.require (internal/modules/cjs/loader.js:903:19)"," at require (internal/modules/cjs/helpers.js:74:18)"," at Object.<anonymous> (/var/task/src/node_modules/canvas/lib/bindings.js:3:18)"," at Module._compile (internal/modules/cjs/loader.js:1015:30)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)"," at Module.load (internal/modules/cjs/loader.js:879:32)"," at Function.Module._load (internal/modules/cjs/loader.js:724:14)"]}

I’ve used Google a lot and apparently libuuid isn’t installed on the AWS Lambda server or something like that, I’m not sure. I’ve come across a lot of issues with this that have been resolved by using a Lambda Layer someone made but you can’t install that with Netlify.

How did I build?
When I upload my site directory to Github I’m not uploading the node_modules directory and thus also not the compiled binaries addons. So while Netlify is building it’s installing the node packages themselves because if it were to use the packages I build on my local machine then I would get an “Invalid ELF header” error.
I also tried to use some build commands that might be able to install the libuuid library for me but none of them worked (yum, apt-get, su, pacman, dnf). I also tried to install the node packages with Docker Desktop but that was totally new to me and I couldn’t get it to work. I know nothing about Linux and its commands.

Here is a build log of a successful build (so without any unknown build commands). I’ve got two functions and this is about the image.js function. I started this build without cache. I’m not sure if this is useful for anyone but just to be sure I’m giving it to you guys! :smiley:

Successfullo no cache build log

12:25:56 PM: Build ready to start 12:25:58 PM: build-image version: 53b83b6bede2920f236b25b6f5a95334320dc849 12:25:58 PM: build-image tag: v3.6.0 12:25:58 PM: buildbot version: a706ec7a557bcc28584843816a376a10c08955ca 12:25:58 PM: Building without cache 12:25:58 PM: Starting to prepare the repo for build 12:25:58 PM: No cached dependencies found. Cloning fresh repo 12:25:58 PM: git clone https://github.com/ImPlotzes/Website-test 12:26:01 PM: Preparing Git Reference refs/heads/main 12:26:03 PM: Starting build script 12:26:03 PM: Installing dependencies 12:26:03 PM: Python version set to 2.7 12:26:05 PM: v12.18.0 is already installed. 12:26:05 PM: Now using node v12.18.0 (npm v6.14.4) 12:26:05 PM: Started restoring cached build plugins 12:26:05 PM: Finished restoring cached build plugins 12:26:05 PM: Attempting ruby version 2.7.1, read from environment 12:26:07 PM: Using ruby version 2.7.1 12:26:07 PM: Using PHP version 5.6 12:26:07 PM: Started restoring cached node modules 12:26:07 PM: Finished restoring cached node modules 12:26:07 PM: Installing NPM modules using NPM version 6.14.4 12:26:14 PM: > canvas@2.6.1 install /opt/build/repo/node_modules/canvas 12:26:14 PM: > node-pre-gyp install --fallback-to-build 12:26:15 PM: node-pre-gyp WARN Using needle for node-pre-gyp https download 12:26:16 PM: [canvas] Success: "/opt/build/repo/node_modules/canvas/build/Release/canvas.node" is installed via remote 12:26:16 PM: npm WARN apiv1@1.0.0 No repository field. 12:26:16 PM: added 80 packages from 37 contributors and audited 80 packages in 8.449s 12:26:17 PM: 4 packages are looking for funding 12:26:17 PM: run npm fund for details 12:26:17 PM: found 0 vulnerabilities 12:26:17 PM: NPM modules installed 12:26:17 PM: Started restoring cached go cache 12:26:17 PM: Finished restoring cached go cache 12:26:17 PM: go version go1.14.4 linux/amd64 12:26:17 PM: go version go1.14.4 linux/amd64 12:26:17 PM: Installing missing commands 12:26:17 PM: Verify run directory 12:26:18 PM: ​ 12:26:18 PM: ──────────────────────────────────────────────────────────────── 12:26:18 PM: Netlify Build 12:26:18 PM: ──────────────────────────────────────────────────────────────── 12:26:18 PM: ​ 12:26:18 PM: ❯ Version 12:26:18 PM: @netlify/build 8.0.3 12:26:18 PM: ​ 12:26:18 PM: ❯ Flags 12:26:18 PM: deployId: 60002a44cd98a4ada2a32149 12:26:18 PM: mode: buildbot 12:26:18 PM: ​ 12:26:18 PM: ❯ Current directory 12:26:18 PM: /opt/build/repo 12:26:18 PM: ​ 12:26:18 PM: ❯ Config file 12:26:18 PM: /opt/build/repo/netlify.toml 12:26:18 PM: ​ 12:26:18 PM: ❯ Context 12:26:18 PM: production 12:26:18 PM: ​ 12:26:18 PM: ──────────────────────────────────────────────────────────────── 12:26:18 PM: 1. Functions bundling 12:26:18 PM: ──────────────────────────────────────────────────────────────── 12:26:18 PM: ​ 12:26:18 PM: Packaging Functions from apiv1 directory: 12:26:18 PM: - image/image.js 12:26:18 PM: - wizcount/wizcount.js 12:26:48 PM: ​ 12:26:48 PM: (Functions bundling completed in 29.6s) 12:26:48 PM: ​ 12:26:48 PM: ──────────────────────────────────────────────────────────────── 12:26:48 PM: Netlify Build Complete 12:26:48 PM: ──────────────────────────────────────────────────────────────── 12:26:48 PM: ​ 12:26:48 PM: (Netlify Build completed in 29.7s) 12:26:48 PM: Caching artifacts 12:26:48 PM: Started saving node modules 12:26:48 PM: Finished saving node modules 12:26:48 PM: Started saving build plugins 12:26:48 PM: Finished saving build plugins 12:26:48 PM: Started saving pip cache 12:26:48 PM: Finished saving pip cache 12:26:48 PM: Started saving emacs cask dependencies 12:26:48 PM: Finished saving emacs cask dependencies 12:26:48 PM: Started saving maven dependencies 12:26:48 PM: Finished saving maven dependencies 12:26:48 PM: Started saving boot dependencies 12:26:48 PM: Finished saving boot dependencies 12:26:48 PM: Started saving rust rustup cache 12:26:49 PM: Finished saving rust rustup cache 12:26:49 PM: Started saving rust cargo bin cache 12:26:49 PM: Finished saving rust cargo bin cache 12:26:49 PM: Started saving go dependencies 12:26:49 PM: Finished saving go dependencies 12:26:51 PM: Build script success 12:26:51 PM: Starting to deploy site from '' 12:26:51 PM: Creating deploy tree 12:26:51 PM: Creating deploy upload records 12:26:52 PM: 0 new files to upload 12:26:52 PM: 2 new functions to upload 12:26:56 PM: Starting post processing 12:26:56 PM: Post processing - HTML 12:26:56 PM: Post processing - header rules 12:26:56 PM: Post processing - redirect rules 12:26:56 PM: Post processing done 12:26:56 PM: Site is live ✨ 12:27:15 PM: Finished processing build request in 1m16.909596769s

Pastebin
https://pastebin.com/8KJ2BsyN

How do I fix this error?

hi there, sorry to be slow to get back to you. we were a little stumped ourselves! any progress at all on this? :thinking:

Sadly no, but I haven’t really done tried anything new. Just trying the stuff I already tried with the hopes of getting a different result. I don’t really know what new things I can try :thinking: