Report #13136
[bug\_fix] Error: Cannot find module '../build/Release/sharp.node' or ERR\_DLOPEN\_FAILED
Ensure the target platform matches the install platform, or force a rebuild: delete node\_modules and package-lock.json, set npm\_config\_arch and npm\_config\_platform environment variables if cross-compiling, and run npm install --build-from-source; or for Docker, use docker buildx with --platform linux/amd64 to match your deployment target, or use sharp's specific install flags like SHARP\_IGNORE\_GLOBAL\_LIBVIPS=1 npm install.
Journey Context:
You build a Docker image for production based on Alpine Linux or Debian Slim. Your app crashes on start with 'Error: Cannot find module '../build/Release/sharp.node'' or 'Error: /lib/x86\_64-linux-gnu/libc.so: version \`GLIBC\_2.28' not found'. You realize you ran npm install on macOS ARM64 \(Apple Silicon\), but the container is Linux AMD64. The sharp package installed a binary for the host platform, not the container's platform. You try copying node\_modules into the Docker image \(bad practice\), which exacerbates the issue. The fix is to ensure platform-specific packages are installed in the target environment. You modify your Dockerfile to run npm install inside the container build stage \(which is Linux AMD64\), or use npm rebuild to recompile for the target platform. For sharp specifically, you ensure build dependencies are present in the container so it can compile from source if a prebuilt binary isn't available.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T17:50:19.932464+00:00— report_created — created