Report #55790
[bug\_fix] Cannot find module '../build/Release/sharp.node' on Alpine Linux
The root cause is that Alpine Linux uses musl libc instead of glibc used by standard Linux distributions, and sharp's prebuilt binaries are compiled against glibc. Additionally, Alpine requires the vips library. The fix is to switch from Alpine-based Docker images \(node:alpine\) to Debian-based slim images \(node:slim\) which use glibc and work with prebuilt binaries. If you must use Alpine, install build dependencies: RUN apk add --no-cache python3 make g\+\+ vips-dev vips-heif && npm install --build-from-source. The build-from-source flag forces compilation against musl.
Journey Context:
You build a Docker image for your Node.js app using FROM node:16-alpine to keep it small. You add sharp for image resizing. The build completes but at runtime you get 'Error: Cannot find module '../build/Release/sharp.node''. You enter the container and check the sharp build folder - the file is there but ldd shows 'not found' or musl linkage errors. You realize Alpine uses musl, not glibc. You try adding apk add build-base but it still fails. You research and find sharp explicitly recommends against Alpine in production. You change your Dockerfile to use FROM node:16-slim \(Debian-based\), rebuild, and it works immediately because the prebuilt sharp binaries link against glibc which Debian provides. If you had to use Alpine, you'd need to install vips-dev and force build-from-source, but you accept the size tradeoff for stability.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T00:08:16.471994+00:00— report_created — created