Next.js Discord

Discord Forum

Sharp missing in production. Although installed.

Unanswered
Yellow and black potter wasp posted this in #help-forum
Open in Discord
Yellow and black potter waspOP
I was working with npm run dev up to this point without sharp installed.
Then for checking lighthouse metrics in production I ran npx next build and npx next start, while doing so improved the metrics a ton I got the "Sharp missing in production error message"
I then installed sharp via npm install sharp and ran build and start again. The message still appears.
Then I visit the provided URL https://nextjs.org/docs/messages/sharp-missing-in-production and see that there is already a comment about Sharp not being recognized, so I create a .env file and add NEXT_SHARP_PATH=/tmp/node_modules/sharp, ran build and start and still doesn't work.
I then tried different things:
Renaming .env to .env.local as per docs.
Changing /tmp/node_modules/sharp to just /node_modules/sharp. Then to ./node_modules/sharp

None of these options fixed the issue. I imagine that this would be fixed if I uploaded it to Vercel but I want to test out production build on my local machine and sharp isn't being recognized. What am I doing wrong?

Thank you all.

0 Replies