Sharp required for standalone mode #40125
Replies: 11 comments 24 replies
-
I am having a similar issue. Try this approach, if it doesn't work, see below. But I am not sure about setting the env variable. |
Beta Was this translation helpful? Give feedback.
-
I solved with added several command in dockerfile :
also if you use same image for deps, builder, and runner. I just add "RUN npm i sharp" in runner section to solved this. |
Beta Was this translation helpful? Give feedback.
-
I, on the other end, simply had to add
in my |
Beta Was this translation helpful? Give feedback.
-
Referring to issue: #59516 I have solved by downgrading |
Beta Was this translation helpful? Give feedback.
-
ENV NEXT_SHARP_PATH=/dspyt/node_modules/sharp worked for me |
Beta Was this translation helpful? Give feedback.
-
If you are stuck on an old version of sharp (like 0.32.6), I have news for you: The Vercel team has fixed things that prevented newer versions of sharp from working. I just shipped a project using the latest sharp version ( |
Beta Was this translation helpful? Give feedback.
-
This should be fixed now on canary. You can try it out with |
Beta Was this translation helpful? Give feedback.
-
I can not get sharp 0.33.2 to work for the life of me. I'm on next@canary and I've tried every single trick I've found online, and no matter what it does not work. Quite frustrating |
Beta Was this translation helpful? Give feedback.
-
Doing these 2 steps helped me solve the issue :
|
Beta Was this translation helpful? Give feedback.
-
In which phase of the Dockerfile should I add the environment variable? Build or runner? |
Beta Was this translation helpful? Give feedback.
-
Sometimes you can run in to trouble from an annoying npm bug (if you are using npm, instead of really anything better, like yarn or pnpm, or bun - anything) - basically, if you have a partial of optional deps in your node_modules folder on like an M1 (which means you don't have binaries for other platforms like linux/x86 - this is normal, usually npm will only add the optional dep you need to node_modules), and then you do npm i - it'll actually remove the unused optional packages from your package-lock.json file. Why does it do this? Because npm. Anyway, the fix is easy - delete node_modules, and package-lock.json and reinstall with no node_modules, to avoid npm getting confused. Then it will put the missing optional packages in your package-lock.json file. Then all you have to do is remember to do this whenever you add or change anything in your packages... This has worked for me almost every time when I'm forced to use npm. But really, just use anything else other than npm... |
Beta Was this translation helpful? Give feedback.
-
I am using next.js standalone mode and I am following with-docker example quoted on Next.js for containerizing the app.
When run and access the app, I get below error
Error: 'sharp' is required to be installed in standalone mode for the image optimization to function correctly
I have installed 'sharp' and it is part of my node_modules. What am I missing?
Beta Was this translation helpful? Give feedback.
All reactions