7e16538485
## For Contributors ### Improving Documentation - [x] Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - [x] Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### What? Add instructions for using `bun/bunx` where relevant. I only added mentions where npm/yarn/pnpm were all already listed. ### Why Bun can be used as a runtime-agnostic [package manager](https://bun.sh/package-manager) and script runner in any project with a `package.json`. (Sorry, I probably should have consolidated this with https://github.com/vercel/next.js/pull/53467) Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
37 lines
1.2 KiB
Text
37 lines
1.2 KiB
Text
---
|
|
title: 'Install `sharp` to Use Built-In Image Optimization'
|
|
---
|
|
|
|
## Why This Error Occurred
|
|
|
|
Using Next.js' built-in [Image Optimization](/docs/pages/building-your-application/optimizing/images) requires [sharp](https://www.npmjs.com/package/sharp) as a dependency.
|
|
|
|
You are seeing this error because your OS was unable to [install sharp](https://sharp.pixelplumbing.com/install) properly, either using pre-built binaries or building from source.
|
|
|
|
## Possible Ways to Fix It
|
|
|
|
Option 1: Use a different version of Node.js and try to install `sharp` again.
|
|
|
|
```bash filename="Terminal"
|
|
npm i sharp
|
|
```
|
|
|
|
```bash filename="Terminal"
|
|
yarn add sharp
|
|
```
|
|
|
|
```bash filename="Terminal"
|
|
pnpm add sharp
|
|
```
|
|
|
|
```bash filename="Terminal"
|
|
bun add sharp
|
|
```
|
|
|
|
Option 2: If using macOS, ensure XCode Build Tools are installed and try to install `sharp` again.
|
|
|
|
For example, see [macOS Catalina instructions](https://github.com/nodejs/node-gyp/blob/66c0f0446749caa591ad841cd029b6d5b5c8da42/macOS_Catalina.md).
|
|
|
|
Option 3: Use a different OS and try to install `sharp` again.
|
|
|
|
For example, if you're using Windows, try using [WSL](https://docs.microsoft.com/en-us/windows/wsl/about) (Windows Subsystem for Linux).
|