Sharp Missing In Production
Why This Error Occurred
The next/image
component's default loader uses squoosh
because it is quick to install and suitable for a development environment.
- For a production environment using
next start
, it is strongly recommended you installsharp
.
You are seeing this error because Image Optimization in production mode (next start
) was detected.
- For a production environment using
output: "standalone"
, you must installsharp
.
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:
Terminal
npm i sharp
Terminal
yarn add sharp
Terminal
pnpm add sharp
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 theNEXT_SHARP_PATH
environment variable such asexport NEXT_SHARP_PATH=/tmp/node_modules/sharp
. Then, build your project withnext build
. Finally, restart the server with eithernext start
for production mode ornode .next/standalone/server.js
for standalone mode.
Note: This is not necessary for Vercel deployments, since
sharp
is installed automatically for you.
Useful Links
Was this helpful?