Skip to content

sharp 0.35.3 fails to load on Vercel (Next.js 16 Server Actions) with ERR_DLOPEN_FAILED: libvips-cpp.so.8.18.3 #4567

Description

@lion9010

Possible bug

Is this a possible bug in a feature of sharp, unrelated to installation?

  • Running npm install sharp completes without error.
  • Running node -e "import 'sharp'" completes without error.

Are you using the latest version of sharp?

  • I am using the latest version of sharp as reported by npm view sharp dist-tags.latest.

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

Please replace this section with the output of:

npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp

Does this problem relate to file caching?

  • Adding sharp.cache(false) does not fix this problem.

Does this problem relate to images appearing to have been rotated by 90 degrees?

  • Using rotate() or keepExif() does not fix this problem.

What are the steps to reproduce?

  1. Create a Next.js 16.2.10 application.
  2. Deploy it to Vercel.
  3. Install sharp@0.35.3.
  4. Create a Server Action that imports sharp and processes an uploaded image.
  5. Execute the Server Action.

The application builds and deploys successfully.

The error only occurs when the Server Action is executed.

Downgrading to sharp@0.34.4 without changing any application code makes the problem disappear.

What is the expected behaviour?

sharp should load successfully and process the image during execution of the Server Action.

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem

"use server";

import sharp from "sharp";

export async function convert(file: File) {
  const buffer = Buffer.from(await file.arrayBuffer());

  return await sharp(buffer)
    .webp({ quality: 80 })
    .toBuffer();
}

At runtime, Vercel throws:

Error: Failed to load external module sharp-xxxxxxxx

Could not load the "sharp" module using the linux-x64 runtime

ERR_DLOPEN_FAILED:
libvips-cpp.so.8.18.3: cannot open shared object file: No such file or directory

Stack trace includes:

.next/server/chunks/ssr/[turbopack]_runtime.js

Additional information:

  • Next.js 16.2.10
  • Vercel
  • Turbopack
  • pnpm 11.9.0
  • Linux x64 runtime
  • @img/sharp-linux-x64 is installed successfully during deployment
  • The application builds successfully
  • The failure occurs only at runtime
  • Downgrading to sharp@0.34.4 resolves the issue immediately

I'm not yet sure whether this is a regression in sharp 0.35.x or an incompatibility with the current Next.js/Vercel packaging. I'm happy to provide a minimal reproduction repository if needed.

Please provide sample image(s) that help explain this problem

The issue is independent of the input image. Any valid JPEG image reproduces the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions