# Error: Could not load the "sharp" module using the linux-x64 runtime — how to fix it

> Could not load the "sharp" module using the linux-x64 runtime means sharp found no prebuilt binary for the Linux machine it runs on. Since sharp 0.33 that binary is a separate optional package, @img/sharp-linux-x64, and it goes missing when node_modules was installed on a Mac or Windows and copied over, when the lockfile was made on another platform, or when optional dependencies were skipped. Install on the Linux machine with optional dependencies included, or add the Linux package to the lockfile.

Source: https://livops.dev/en/guides/error-sharp-could-not-load-linux-x64-runtime

By Livops team, the people who build and run Livops. Updated 3 December 2026.

The error, as Node prints it when sharp 0.35 runs on a Linux x64 server without its Linux binary, followed by a stack trace[2]:

```text
Error: Could not load the "sharp" module using the linux-x64 runtime
Possible solutions:
- Ensure optional dependencies can be installed:
    npm install --include=optional sharp
- Ensure your package manager supports multi-platform installation:
    See https://sharp.pixelplumbing.com/install#cross-platform
- Add platform-specific dependencies:
    npm install --os=linux --cpu=x64 sharp
- Consult the installation documentation:
    See https://sharp.pixelplumbing.com/install
```

The runtime in the first line changes with the machine: `linuxmusl-x64` on Alpine, `linux-arm64` on an ARM server[3]. On Alpine the suggested command gains `--libc=musl`[2]. sharp 0.32 and older printed different text for the same problem[7]:

```text
Something went wrong installing the "sharp" module
...
- Install for the current linux-x64 runtime: "npm install --platform=linux --arch=x64 sharp"
```

This page explains how sharp picks its binary, the causes in the order they usually happen, the fix for each, and how to check it before you deploy.

## What does the error mean?

### sharp's binary is a separate package per platform

sharp is a native module: it runs compiled sharp and libvips binaries[1]. Since sharp 0.33.0 those prebuilt binaries are distributed through the npm registry and installed by your package manager[6]. sharp lists one optional dependency per platform, such as `@img/sharp-linux-x64`, `@img/sharp-linuxmusl-x64` and `@img/sharp-darwin-arm64`[4], and each says which system it is for: `@img/sharp-linux-x64` is for Linux, x64 and glibc[5]. At install time the package manager picks the binaries for the current operating system and CPU[1], and skips the rest.

### What happens when sharp loads

sharp names the machine it runs on: the platform, then `musl` on a Linux that does not use glibc, then the CPU, as in `linux-x64` or `linuxmusl-x64`[3]. It then tries a binary built from source, the package for that runtime (`@img/sharp-linux-x64` for `linux-x64`), and the WebAssembly package `@img/sharp-wasm32`; when none of them loads, it throws this error[2]. So in practice the error means **`node_modules/@img/sharp-linux-x64` is not there**. Check on the failing machine:

```sh
ls node_modules/@img/
npm ls sharp
```

### Read the Possible solutions lines

sharp chooses the suggestions by what went wrong[2]:

| The error shows | What it means |
| --- | --- |
| `Ensure optional dependencies can be installed` and `Add platform-specific dependencies` | The platform has a prebuilt binary, but its package is missing: causes 1 to 4 below |
| `Please upgrade Node.js` with `Found` and `Requires` | Node is older than sharp supports: cause 5 |
| `Unsupported CPU: Prebuilt binaries for Linux x64 require v2 microarchitecture` | The CPU is too old for the prebuilt binary: cause 7 |
| `Update your OS` with a glibc or musl version | The system's C library is older than the binary needs: cause 7 |

## Causes, most common first

### 1. node_modules was installed on a Mac or Windows and copied to Linux

You ran `npm install` on a laptop, and the `node_modules` folder travelled to the server: a Dockerfile that copies the whole project folder, a `.zip` with `node_modules` in it, or `rsync` to a VPS. On the laptop the package manager installed the macOS or Windows binary only[1]; `@img/sharp-linux-x64` is for Linux[5], so it was skipped. On the server sharp finds no Linux package and stops[2].

**Fix:** never ship `node_modules`; install on the Linux machine. In a Dockerfile, copy `package.json` and the lockfile, run the install inside the image, and add `node_modules` to `.dockerignore` so the laptop's copy does not overwrite it:

```dockerfile
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
```

### 2. The lockfile was written on another platform

sharp's docs warn that a `package-lock.json` shared by several platforms can cause installation problems, because of npm bug #4828[1]. That issue is about platform-specific optional dependencies left out of `package-lock.json` when you reinstall with `node_modules` present[9]. When the Linux package is not in the lockfile, the install on the server has nothing to fetch for Linux. Check:

```sh
grep -c '"node_modules/@img/sharp-linux-x64"' package-lock.json
```

`0` means the Linux package is missing. **Fix:** for npm 10 and later, sharp's docs add the other platform with the `--os`, `--cpu` and `--libc` flags, and for a Linux target the C library must be named[1]:

```sh
# Linux x64 with glibc (Debian, Ubuntu)
npm install --cpu=x64 --os=linux --libc=glibc sharp
# Linux x64 with musl (Alpine)
npm install --cpu=x64 --os=linux --libc=musl sharp
```

These flags override the operating system, CPU and C library of the native modules npm installs[8]. Commit `package-lock.json` and run the `grep` again. With yarn 3 or later, or pnpm 8 or later, sharp's docs point to their `supportedArchitectures` setting instead[1].

### 3. Optional dependencies were skipped

sharp's binaries are optional dependencies[4], and its docs ask you to make sure the package manager installs them[1]. `npm install --omit=optional` leaves optional dependencies off the disk, even though they are still resolved into `package-lock.json`[8]. The older `--no-optional` flag is a deprecated alias for the same thing[8]. Look for it in the install command, in CI scripts and in `.npmrc` (`omit=optional`).

**Fix:** remove it, or install sharp with optional dependencies included, the first suggestion in the error[2]:

```sh
npm install --include=optional sharp
```

If a dependency type is in both `--include` and `--omit`, npm includes it[8].

**Next.js.** Next.js 16.5.0 lists `sharp` itself as an optional dependency[11], so `--omit=optional` drops it too. For `next start` Next.js strongly recommends sharp, and for `output: "standalone"` it says you must install it[10]. See [Next.js hosting](https://livops.dev/en/hosting/nextjs-hosting).

### 4. glibc binaries on Alpine, or musl binaries on Debian

On Alpine, sharp's runtime is `linuxmusl-x64`[3], and it needs `@img/sharp-linuxmusl-x64`[2]. A multi-stage Dockerfile that installs dependencies on a Debian-based image and copies `node_modules` into an Alpine one carries only the glibc package across, and the error names `linuxmusl-x64`. **Fix:** install in the same base image that runs the app, or add both C libraries to the lockfile with the two commands in cause 2. The prebuilt binaries need glibc 2.28 or later, or musl 1.2.5 or later, on x64[1].

### 5. Node.js is older than sharp needs

sharp 0.35.6 requires Node `>=20.9.0`[4]; its docs ask for a Node-API v9 runtime such as Node.js 20.9.0 or later[1]. On an older Node the suggestions are replaced by `Please upgrade Node.js` with the version found and the one required[2][3]. **Fix:** upgrade Node, for example in `.nvmrc`. sharp 0.33.0 itself required Node `^18.17.0` or `>=20.3.0`[6].

### 6. sharp 0.32 or older: Something went wrong installing

The old message comes from sharp 0.32 and earlier, whose loader looked for one binary inside the package and suggested reinstalling with `--platform` and `--arch`[7]. From 0.33.0 the binaries come through the package manager instead[6]. **Fix:** move to a current sharp, then reinstall on the target machine:

```sh
npm install sharp@latest
npm ls sharp
```

Check sharp's changelog for breaking changes between your version and the new one.

### 7. Rare: an old CPU or an old C library

Linux x64 prebuilt binaries need a CPU with SSE4.2, and glibc 2.28 or musl 1.2.5 or later[1]. Below that, the error adds `Unsupported CPU: Prebuilt binaries for Linux x64 require v2 microarchitecture`, or `Update your OS` with the C library it found and the one it needs[2]. **Fix:** a newer machine or base image. Building sharp from source (`npm explore sharp -- npm run build`) is the other way, and it needs a C++17 compiler and node-gyp[1]; see [node-gyp rebuild failed](https://livops.dev/en/guides/error-node-gyp-rebuild-failed) for what that takes.

## How to check the fix before you deploy

Install the committed code in a clean Linux container, the way a server would, and load sharp:

```sh
git clone . /tmp/sharp-check
docker run --rm -v /tmp/sharp-check:/app -w /app node:22-slim \
  sh -c 'npm ci && node -e "import(\"sharp\").then(() => console.log(\"sharp loads\"))"'
```

`sharp loads` means the lockfile brings the Linux binary with it. To test Alpine, use `node:22-alpine` instead. If `npm ci` itself complains that the lockfile and `package.json` do not match, see [npm ci: lockfile out of sync](https://livops.dev/en/guides/error-npm-ci-lockfile-out-of-sync).

## On Livops

- **An uploaded folder never brings node_modules.** When you upload a folder or a `.zip`, `node_modules` is dropped automatically, and Livops installs the dependencies itself. So cause 1 cannot come from an upload; see [Ways to deploy](https://livops.dev/en/docs/deploy).
- **Commit the lockfile with Linux in it.** For a GitHub project, run the `grep` from cause 2 and commit `package-lock.json` once it lists the Linux package.
- **Check the install command.** Livops detects the framework and picks the install command; you can change it under **Settings → Install**, or with `install` in `livops.json`, which is applied on every deploy. Keep `--omit=optional` and `--no-optional` out of it; `npm ci --include=optional` is fine. See [Frameworks and livops.json](https://livops.dev/en/docs/frameworks).
- **Node 22 or 24.** Those are the Node versions Livops has, and both are newer than sharp's minimum, so cause 5 does not apply unless you pinned an older sharp. Livops reads `.nvmrc` and `.node-version`.
- **Your own Dockerfile.** If the repository has a `Dockerfile`, it is used, and causes 1 and 4 then come from what it copies and which base image it uses.
- **Where the error shows.** If the build step loads sharp, the deploy fails as `build_failed` with the error in the build log, and the [assistant](https://livops.dev/en/docs/assistant) explains it. If the app loads sharp when it starts, the deploy fails as `start_failed`, with the error on the **Logs** page; see [The app did not start](https://livops.dev/en/docs/error-start). If it loads sharp only when it first handles an image, the deploy itself can succeed, and the error appears on the **Logs** page when that first image request comes in; `livops logs <service> -f` follows it from the terminal.

A Node app costs **39 credits a month** (39,000 so'm); see [Pricing](https://livops.dev/en/docs/pricing).

If the install stops earlier, on a native addon that compiles, see [node-gyp rebuild failed](https://livops.dev/en/guides/error-node-gyp-rebuild-failed); if Node cannot find a module at all, see [Cannot find module](https://livops.dev/en/guides/error-node-cannot-find-module).

## Questions

**What does Could not load the sharp module using the linux-x64 runtime mean?**

sharp runs on Linux with an x64 CPU and glibc, and it could not load a binary for that platform. Since sharp 0.33 that binary comes in a separate optional package, @img/sharp-linux-x64, which the package manager installs only on a matching machine. The error almost always means that package is not in node_modules.

**Why does sharp work on my Mac but not on the server?**

On a Mac the package manager installed the macOS binary, such as @img/sharp-darwin-arm64, and nothing for Linux. If that node_modules folder is copied to a Linux server, or the lockfile was written without the Linux packages, the server has no binary it can load. Install the dependencies on the server itself.

**How do I add the Linux binary to package-lock.json from a Mac?**

sharp's installation docs give npm install --cpu=x64 --os=linux --libc=glibc sharp for Debian-style Linux and the same with --libc=musl for Alpine. When the target is Linux the C library must be named. Commit the lockfile, then check that it lists node_modules/@img/sharp-linux-x64.

**Does npm install --omit=optional break sharp?**

Yes. sharp ships its binaries as optional dependencies, and --omit=optional, or the older --no-optional, leaves them out of node_modules even though the lockfile still lists them. sharp's docs ask that the package manager installs optional dependencies, and the error itself suggests npm install --include=optional sharp.

**What is the linuxmusl-x64 runtime?**

It is Linux on x64 with the musl C library, as on Alpine. sharp names its runtime by platform, C library and CPU, so on Alpine the error says linuxmusl-x64 and needs the @img/sharp-linuxmusl-x64 package. A node_modules installed on a glibc system such as Debian does not have it.

**What about Something went wrong installing the sharp module?**

That is the same problem in sharp 0.32 and older, which used a different loader and error text. From 0.33.0 the prebuilt binaries come from the npm registry through the package manager. Upgrading to a current sharp and installing on the target machine is the usual fix.

## Sources

1. [sharp — Installation](https://sharp.pixelplumbing.com/install/). Checked 3 December 2026.
2. [sharp v0.35.6 source — lib/sharp.mjs](https://github.com/lovell/sharp/blob/v0.35.6/lib/sharp.mjs). Checked 3 December 2026.
3. [sharp v0.35.6 source — lib/libvips.mjs](https://github.com/lovell/sharp/blob/v0.35.6/lib/libvips.mjs). Checked 3 December 2026.
4. [sharp v0.35.6 source — package.json](https://github.com/lovell/sharp/blob/v0.35.6/package.json). Checked 3 December 2026.
5. [sharp v0.35.6 source — npm/linux-x64/package.json (@img/sharp-linux-x64)](https://github.com/lovell/sharp/blob/v0.35.6/npm/linux-x64/package.json). Checked 3 December 2026.
6. [sharp — Changelog v0.33.0](https://sharp.pixelplumbing.com/changelog/v0.33.0/). Checked 3 December 2026.
7. [sharp v0.32.6 source — lib/sharp.js](https://github.com/lovell/sharp/blob/v0.32.6/lib/sharp.js). Checked 3 December 2026.
8. [npm Docs — config (omit, include, optional, os, cpu, libc)](https://docs.npmjs.com/cli/v11/using-npm/config/). Checked 3 December 2026.
9. [npm/cli issue 4828 — platform-specific optional dependencies not included in package-lock.json](https://github.com/npm/cli/issues/4828). Checked 3 December 2026.
10. [Next.js Docs — Sharp Missing In Production](https://nextjs.org/docs/messages/sharp-missing-in-production). Checked 3 December 2026.
11. [Next.js v16.5.0 source — packages/next/package.json](https://github.com/vercel/next.js/blob/v16.5.0/packages/next/package.json). Checked 3 December 2026.
