Skip to content

Turbopack: 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

Closed

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 [email protected].
  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 [email protected] 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 [email protected] 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.

Activity

  1. dishb commented on Jul 11, 2026

    @dishb

    I've been having this exact issue for about 6 hours. I was using Next.js v16.2.9, sharp v0.35.3, pnpm v10.28.0, and Node.js v24.x.x. I was so confused because when developing my API locally (on macOS), I would have no issues at all. The Vercel build itself had no issues. However, as soon as I tried to use the API endpoint that utilized sharp for some functionality, I would get these 2 errors:

    2026-07-11 01:07:23.297 [error] Failed to handle /api/proxy/try-on?shop=[REDACTED].myshopify.com&logged_in_customer_id=&path_prefix=%2Fapps%2Fvton&timestamp=1783732042&signature=[REDACTED] Error: Failed to load external module sharp-5843a61b03cbf433: Error: 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
    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
        at Context.externalImport [as y] (.next/server/chunks/[turbopack]_runtime.js:607:15)
        at async (.next/server/chunks/[root-of-the-server]__10i3ymo._.js:36:40011)
    

    and

    Error: Failed to load external module sharp-5843a61b03cbf433: Error: 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
    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
        at Context.externalImport [as y] (.next/server/chunks/[turbopack]_runtime.js:607:15)
        at async (.next/server/chunks/[root-of-the-server]__10i3ymo._.js:36:40011)
    

    For a little bit of context, I am developing an API using Next.js app router and deploying to Vercel. Everything is server-side (because it's an API). I use sharp in a function that the API calls, and this was causing these errors. I tried everything from ensuring optional dependencies were installed by pnpm, adding sharp to my approve build scripts, etc. My build command is next build so I assume it's not a Turbopack issue (which is something I saw when researching).

    These are the various links I tried looking at:

    Somehow, I never found this issue until now! None of the solutions posted in these issues and discussions worked for me. Only downgrading worked. Also, I notice in the issue template it asks about using rotate(); my code does use rotate() but I still have the issue with the missing binaries.

    @lion9010 Thank you so, so, so much for mentioning that the downgrade to [email protected] fixes the issue - I haven't found this anywhere else.

  2. lovell commented on Jul 11, 2026

    @lovell
    Owner

    Hi, both these comments mention Turbopack, are you able to try without it?

    I ask as the latest version of sharp should "just work" with most bundlers - see vercel/nft#594 (comment) - but maybe not Turbopack, which currently has "special case" logic that might need changing/removing.

  3. dishb commented on Jul 13, 2026

    @dishb

    Hi, both these comments mention Turbopack, are you able to try without it?

    Just checked - it looks like my project was using Turbopack because it's the default with Next.js v16.x.x. Apologies, I wasn't aware of this before.

    I just tried my project using next build --webpack and sharp v0.35.3, and the API worked completely fine. Looks like Turbopack is the issue?

  4. lovell commented on Jul 15, 2026

    @lovell
    Owner

    Thanks for confirming, please can you open an issue against Turbopack and link back to this issue and perhaps my comment at vercel/nft#594 (comment) also.

  5. changed the title [-]sharp 0.35.3 fails to load on Vercel (Next.js 16 Server Actions) with ERR_DLOPEN_FAILED: libvips-cpp.so.8.18.3[/-] [+]Turbopack: sharp 0.35.3 fails to load on Vercel (Next.js 16 Server Actions) with ERR_DLOPEN_FAILED: libvips-cpp.so.8.18.3[/+] on Jul 15, 2026
  6. dishb commented on Jul 17, 2026

    @dishb

    Thanks for confirming, please can you open an issue against Turbopack and link back to this issue and perhaps my comment at vercel/nft#594 (comment) also.

    While I was doing this, I found that my minimal reproducible example (dishb/turbopack-sharp) doesn't have the issue?? Maybe it's because the project uses [email protected] instead of the stable release [email protected] which I was using previously. I did this because the issue template instructions said to do so before raising an issue.

    The API code is pretty much exactly how I use sharp in my actual project where I was getting the error. I'm not a seasoned developer (Next.js or sharp) at all, so if anyone else wants to take a look at this 😅

  7. dishb commented on Jul 17, 2026

    @dishb

    Yes, even in my original project where I got those big error messages, switching to [email protected] and [email protected] fixed the issue; my API works completely fine, and I don't see the errors in my Vercel logs. Still using Turbopack.

    The Next.js reproduction template says the issues must be verified against the next@canary release.

  8. lovell commented on Jul 17, 2026

    @lovell
    Owner

    Thanks, definitely looks like a recent change/fix in Turbopack.

  9. soulchild commented on Jul 22, 2026

    @soulchild

    I was about to lose my mind over this after upgrading sharp due to the recently discovered high severity CVEs.

    At the time of writing sharp 0.35.x just doesn't work with Next.js 16.2 (Turbopack).

    This has apparently already been fixed in Next.js 16.3 and I hope that the fix gets backported to 16.2 (or 16.3 gets released soonish) because I'd really like to have these sharp CVEs fixed in my apps.

  10. 6 remaining items

  11. lovell commented on Jul 24, 2026

    @lovell
    Owner

    @homersimpsons For Nuxt please see unjs/nf3#48

  12. wen- commented on Jul 30, 2026

    @wen-

    This solution can be used as a reference:

    In Next.js 16.2.xx, optionalDependencies corresponds to sharp: ^ 0.34.5
    In Next.js 16.3.xx, optionalDependencies corresponds to sharp: ^ 0.35.3

    If want to use sharp: 0.35.3 in Next.js 16.2.xx, simply overwrite the version in package.json:

    If using npm
    "overrides": {
    "sharp": "0.35.3"
    }

    If using yarn
    "resolutions": {
    "sharp": "0.35.3"
    }

    If not overwrite, two different versions of libvips-cpp.so.8.17.3 and libvips-cpp.so.8.18.3 will be installed,
    When using modules, only the old version directory is searched for the new version, so an error message will appear indicating that libvips-cpp.so.8.18.3 cannot be found

  13. userquin commented on Jul 30, 2026

    @userquin
  14. lovell commented on Jul 30, 2026

    @lovell
    Owner

    @userquin It looks like you're using the @vite-pwa/assets-generator package, please see vite-pwa/assets-generator#69, this issue relates to Turbopack.

  15. userquin commented on Jul 30, 2026

    @userquin

    sorry 🙏 , didn't notice Turbopack: prefix at title, anyway, fixed on my local thx

    Using sharp with a pnpm monorepo will use root node_modules even if I exclude the example from root, it using its own pnpm workspace + lock files: sharp installed inside its own node_modules but not beig used

  16. jtstothard commented on Aug 4, 2026

    @jtstothard

    Tracking for downstream consumers on Vercel (Next.js 16 + Turbopack). We've pinned to 0.34.2 in jtstothard/maryomelka pending a fix here — 0.35.3 fails at runtime with ERR_DLOPEN_FAILED: libvips-cpp.so.8.18.3 not traced into the serverless function bundle. 👁️ Watching this issue for a resolution.

  17. lovell commented on Aug 26, 2026

    @lovell
    Owner

    I'll close as this has been fixed downstream in the latest versions of Next.js 15 and 16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions