Report #70307
[bug\_fix] Error: Could not load the default sharp binary: sharp-linux-x64.node cannot open shared object file
Install sharp for the target runtime platform, not just the build host. Use \`npm install --os=linux --cpu=x64 --libc=glibc sharp\` \(or set \`supportedArchitectures\` in package.json/pnpm-workspace.yaml\). For Alpine use \`--libc=musl\`. If no prebuilt binary exists, build from source after installing libvips-dev, build-essential, and node-gyp.
Journey Context:
You build a Next.js image app on macOS and deploy the \`node\_modules\` to an Ubuntu server. At runtime \`sharp\` throws that it cannot load the default binary because the installed \`.node\` file is for darwin-arm64. sharp selects prebuilt binaries at install time based on \`process.platform\` and \`process.arch\`, so copying \`node\_modules\` across OS/CPU does not work. You add \`supportedArchitectures\` to your pnpm workspace config covering linux-x64 and glibc, reinstall in the CI build stage that matches the server, and the runtime error disappears because the correct native binary is now present.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:35:14.890003+00:00— report_created — created