# Error: Image optimization failed for URL '...' with status 500. Internal error: sharp is not installed.

- **ID:** `nextjs/image-optimization-internal-server-error`
- **Domain:** nextjs
- **Category:** module_error
- **Error Code:** `500`
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Next.js image optimization relies on the 'sharp' library for server-side image processing. When sharp is missing or fails to install (e.g., on certain architectures or serverless environments), the optimization endpoint returns a 500 error.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 13.4.0 | active | — | — |
| 13.5.0 | active | — | — |
| 14.0.0 | active | — | — |
| 14.2.0 | active | — | — |
| 15.0.0 | active | — | — |

## Workarounds

1. **Install sharp explicitly as a production dependency: npm install sharp@latest. Ensure your deployment platform supports sharp (e.g., Vercel, Netlify). For serverless, use next.config.js: experimental: { optimizePackageImports: ['sharp'] }.** (85% success)
   ```
   Install sharp explicitly as a production dependency: npm install sharp@latest. Ensure your deployment platform supports sharp (e.g., Vercel, Netlify). For serverless, use next.config.js: experimental: { optimizePackageImports: ['sharp'] }.
   ```
2. **If sharp cannot be installed, set images.unoptimized: true in next.config.js to disable all image optimization globally, or use a third-party image CDN provider configured via images.loader.** (75% success)
   ```
   If sharp cannot be installed, set images.unoptimized: true in next.config.js to disable all image optimization globally, or use a third-party image CDN provider configured via images.loader.
   ```

## Dead Ends

- **Reinstalling sharp with npm install sharp without specifying the correct platform binary** — The default installation may try to build from source, failing on systems without C++ build tools. It's better to use --ignore-scripts or install platform-specific binaries. (60% fail)
- **Setting unoptimized: true on every Image component as a global workaround** — This disables all image optimization, leading to large unoptimized images, slower page loads, and potential layout shifts. It's a performance regression. (30% fail)
