Report #4281
[bug\_fix] Sharp/libvips binary installation failure \(Cannot find module sharp.node\)
Set environment variable \`SHARP\_IGNORE\_GLOBAL\_LIBVIPS=1\` before installing to force using prebuilt sharp binaries instead of system libvips, or switch from Alpine Linux to Debian-based image \(e.g., \`node:18-slim\` instead of \`node:18-alpine\`\).
Journey Context:
Developer builds a Next.js app locally on macOS with \`sharp\` for image optimization. Everything works. They deploy to Vercel or build a Docker image using \`node:18-alpine\`. The build succeeds but at runtime, the app crashes with \`Error: Cannot find module '../build/Release/sharp.node'\`. The developer SSHs into the container and sees the file exists but \`ldd\` shows missing shared libraries \(\`libvips.so.42\`\). They try installing \`vips-dev\` via apk add, but the version mismatch persists. They realize Alpine uses musl libc while sharp's prebuilt binaries expect glibc. Setting \`SHARP\_IGNORE\_GLOBAL\_LIBVIPS=1\` ensures sharp downloads the correct musl-compatible binary during npm install. Alternatively, switching the Dockerfile to \`node:18-slim\` \(Debian-based\) provides glibc compatibility with standard sharp binaries.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:09:56.382199+00:00— report_created — created