silverwolf-x/project / errors /install-sharp.mdx
silverwolf-x's picture
download
raw
1.28 kB
---
title: 'Install `sharp` to Use Built-In Image Optimization'
---
## Why This Error Occurred
Using Next.js' built-in [Image Optimization](/docs/pages/api-reference/components/image) 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: Try installing the wasm variant of `sharp` by running `npm install --cpu=wasm32 sharp`.
Option 3: 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 4: 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).

Xet Storage Details

Size:
1.28 kB
·
Xet hash:
ac763ebc25017e429ceea93114d49c9a9d51da7bd9384add2bf8c1cf6c7017fe

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.