Repository navigation
Closed
Labels
Description
Possible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
- Running
npm install sharpcompletes 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
sharpas reported bynpm 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()orkeepExif()does not fix this problem.
What are the steps to reproduce?
- Create a Next.js 16.2.10 application.
- Deploy it to Vercel.
- Install
[email protected]. - Create a Server Action that imports
sharpand processes an uploaded image. - 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-x64is 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.
Reacted by mindsolo, Jonatan Duttweiler, dishant b, pharmarin, Aymen, Malte Schweer, Valentin Correa, check24-glenndittmann, Harry Bawsac, Masashi Tomooka and 4 more
Reacted by Valentin Correa
Reacted by Valentin Correa
Activity
dishb commentedon Jul 11, 2026
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:
and
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 buildso I assume it's not a Turbopack issue (which is something I saw when researching).These are the various links I tried looking at:
@vercel/nftdoes not pick up platform-specific binaries forsharpvercel/nft#371Somehow, 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 userotate()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.lovell commentedon Jul 11, 2026
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.
dishb commentedon Jul 13, 2026
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 --webpackand sharp v0.35.3, and the API worked completely fine. Looks like Turbopack is the issue?lovell commentedon Jul 15, 2026
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.
[-]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[/+]Pin sharp to 0.34.4 -- 0.35.x breaks under Turbopack in production
Update dependencies to latest safe versions
dishb commentedon Jul 17, 2026
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 😅
dishb commentedon Jul 17, 2026
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@canaryrelease.lovell commentedon Jul 17, 2026
Thanks, definitely looks like a recent change/fix in Turbopack.
fix: stop logging DB credentials, downgrade sharp for Vercel runtime
soulchild commentedon Jul 22, 2026
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.
6 remaining items
lovell commentedon Jul 24, 2026
@homersimpsons For Nuxt please see unjs/nf3#48
fix(web): downgrade sharp to 0.34.x to fix Vercel/Turbopack native load
fix: downgrade sharp to 0.34.5 to fix Vercel production crash
wen- commentedon Jul 30, 2026
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
userquin commentedon Jul 30, 2026
lovell commentedon Jul 30, 2026
@userquin It looks like you're using the
@vite-pwa/assets-generatorpackage, please see vite-pwa/assets-generator#69, this issue relates to Turbopack.userquin commentedon Jul 30, 2026
sorry 🙏 , didn't notice
Turbopack:prefix at title, anyway, fixed on my local thxUsing 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
fix(cms): pin sharp to 0.34.4 for Vercel runtime compatibility
fix(batch): downgrade sharp to 0.34.5 for Vercel runtime (#6493)
jtstothard commentedon Aug 4, 2026
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.
fix(imagen): downgrade sharp a 0.34.4 — ERR_DLOPEN_FAILED libvips en …
fix(imagen): upload firmado a Cloudinary — resuelve dos causas raíz d…
fix: pin sharp to 0.34.5 to work around Vercel runtime failure
fix(security): Next.jsを16.2.12から16.3.0へ更新し内部sharp/postcss脆弱性を解消 (#2280)
lovell commentedon Aug 26, 2026
I'll close as this has been fixed downstream in the latest versions of Next.js 15 and 16.