mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
3bf570d84d
Closes: - https://linear.app/vercel/issue/DOC-4626/images - https://linear.app/vercel/issue/DOC-4610/split-image-and-font-pages Redirects: https://github.com/vercel/next.js/pull/78769 **Housekeeping:** - Deletes BYA images page - Creates relevant getting started docs in `/pages` - Splits "Images and Fonts" into "Images" and "Fonts" pages to allow us to add more context to each page in the future **API reference**: - Improves image API reference to follow more of a consistent format and language - Adds examples **Follow-up:** https://github.com/vercel/next.js/pull/78857 - Create a Deep Dive Guide on how image optimization works --------- Co-authored-by: Rich Haines <hello@richardhaines.dev>
48 lines
1.9 KiB
Plaintext
48 lines
1.9 KiB
Plaintext
---
|
|
title: Sharp Missing In Production
|
|
---
|
|
|
|
## Why This Error Occurred
|
|
|
|
The `next/image` component's default loader uses [`squoosh`](https://www.npmjs.com/package/@squoosh/lib) because it is quick to install and suitable for a development environment.
|
|
|
|
- For a production environment using `next start`, it is strongly recommended you install [`sharp`](https://www.npmjs.com/package/sharp).
|
|
|
|
You are seeing this error because Image Optimization in production mode (`next start`) was detected.
|
|
|
|
- For a production environment using `output: "standalone"`, you must install [`sharp`](https://www.npmjs.com/package/sharp).
|
|
|
|
You are seeing this error because Image Optimization in standalone mode (`output: "standalone"`) was detected.
|
|
|
|
## Possible Ways to Fix It
|
|
|
|
- Install `sharp` by running one of the following commands in your project directory:
|
|
|
|
```bash filename="Terminal"
|
|
npm i sharp
|
|
```
|
|
|
|
```bash filename="Terminal"
|
|
yarn add sharp
|
|
```
|
|
|
|
```bash filename="Terminal"
|
|
pnpm add sharp
|
|
```
|
|
|
|
```bash filename="Terminal"
|
|
bun add sharp
|
|
```
|
|
|
|
Then, build your project with `next build`. Finally, restart the server with either `next start` for production mode or `node .next/standalone/server.js` for standalone mode.
|
|
|
|
- If `sharp` is already installed but can't be resolved, set the `NEXT_SHARP_PATH` environment variable such as `export NEXT_SHARP_PATH=/tmp/node_modules/sharp`. Then, build your project with `next build`. Finally, restart the server with either `next start` for production mode or `node .next/standalone/server.js` for standalone mode.
|
|
|
|
> **Note**: This is not necessary for Vercel deployments, since `sharp` is installed automatically for you.
|
|
|
|
## Useful Links
|
|
|
|
- [Image Optimization Documentation](/docs/pages/api-reference/components/image)
|
|
- [`next/image` Documentation](/docs/pages/api-reference/components/image)
|
|
- [Output File Tracing](/docs/pages/api-reference/config/next-config-js/output)
|