Next.js: Error: 'sharp' is required to be installed in standalone mode for the image optimization to function correctly
In production/standalone builds, Next.js needs the sharp package to optimise images.
'sharp' is required to be installed in standalone mode for the image optimization to function correctlyError: 'sharp' is required to be installed in standalone modesharp is required Next.js standalone Meaning
Install it (npm i sharp) as a dependency (Next 15 bundles it automatically in many cases; Docker with Alpine may need platform-specific binaries). In standalone Docker images copy node_modules/sharp or set NEXT_SHARP_PATH. Without it images are served unoptimized or fail.
Common causes
- sharp not in dependencies
- Docker multi-stage copy missing sharp
- Alpine/arm64 binary mismatch
- Standalone output without traced sharp
- Using
npm ci --omit=optional
⚡ Quick fix
npm install sharpand rebuild- Dockerfile: install in the runner stage or set
NEXT_SHARP_PATH - Don't omit optional dependencies
Detailed fix by platform
Docker
RUN npm i sharp && ENV NEXT_SHARP_PATH=/app/node_modules/sharp
How to diagnose
- sharp — Installed?
- Image — Docker standalone?
- Optional — Omitted?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- _next/image 400 / upstream image response failed Next.js: ⨯ upstream image response failed for https://example.com/a.jpg 404 / url parameter is not allowed
- Conflicting app and page file was found Next.js: ⨯ Conflicting app and page file was found, please remove the conflicting files to continue: "pages/index.tsx" - "app/page.tsx"
- CORS error calling Next.js API route / route handler Browser: Access to fetch at 'https://api.example.com/api/data' from origin 'https://app.example.com' has been blocked by CORS policy (Next.js route handler)
Most viewed in Next.js
- NEXT_REDIRECT Next.js: Error: NEXT_REDIRECT (redirect() inside try/catch)
- server-only Next.js: You're importing a component that needs "server-only". That only works in a Server Component
- cookies() should be awaited Next.js 15: Route "/x" used `cookies().get('token')`. `cookies()` should be awaited before using its value
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026