Install `sharp` to Use Built-In Image Optimization
Why This Error Occurred
Using Next.js' built-in Image Optimization requires sharp as a dependency.
You are seeing this error because your OS was unable to install sharp 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.
Terminal
npm i sharpTerminal
yarn add sharpTerminal
pnpm add sharpTerminal
bun add sharpOption 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.
Option 4: Use a different OS and try to install sharp again.
For example, if you're using Windows, try using WSL (Windows Subsystem for Linux).
Was this helpful?