# Next.js: Error: 'sharp' is required to be installed in standalone mode for the image optimization to function correctly

**Code:** `'sharp' is required to be installed in standalone mode` · **Category:** Next.js · **Seen on:** Next.js, Docker, Node.js

In production/standalone builds, Next.js needs the `sharp` package to optimise images.

## 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

1. `npm install sharp` and rebuild
2. Dockerfile: install in the runner stage or set `NEXT_SHARP_PATH`
3. Don't omit optional dependencies

## Detailed fix by platform

### Docker

1. `RUN npm i sharp && ENV NEXT_SHARP_PATH=/app/node_modules/sharp`

## How to diagnose

1. **sharp** — Installed?
2. **Image** — Docker standalone?
3. **Optional** — Omitted?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/nextjs/sharp-required-standalone)
