Error: 'sharp' is required to be installed in standalone mode for the image optimization to function
Unanswered
Bluetick Coonhound posted this in #help-forum
Bluetick CoonhoundOP
Here is my Dockerfile:
then, when building, I can see sharp is listed into my node_modules:
So why I get this error message when running the server:
...
FROM base AS runner
WORKDIR /app
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
#
# Copy files
#
# Copy output:"standalone" traces (https://nextjs.org/docs/advanced-features/output-file-tracing)
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
RUN ls -al
RUN ls -al node_modules
#
# Runtime definition
#
USER nextjs
ENV NEXT_TELEMETRY_DISABLED 1
ENV NODE_ENV production
CMD node server.jsthen, when building, I can see sharp is listed into my node_modules:
$ docker build -t myapp .
...
#23 [runner 10/11] RUN ls -al
#23 0.116 total 40
#23 0.116 drwxr-xr-x 1 root root 4096 Oct 25 07:32 .
#23 0.116 drwxr-xr-x 1 root root 4096 Oct 25 07:32 ..
#23 0.116 -rw-r--r-- 1 nextjs nodejs 1828 Oct 25 07:32 .env
...
#24 0.122 drwxr-xr-x 4 nextjs nodejs 4096 Oct 25 07:32 sharp
...So why I get this error message when running the server:
Error: 'sharp' is required to be installed in standalone mode for the image optimization to function correctly. Read more at: https://nextjs.org/docs/messages/sharp-missing-in-production
$ docker run --rm -p 3000:3000 myapp
â–² Next.js 13.5.6
- Local: http://7d8a30f47cb2:3000
- Network: http://172.17.0.2:3000
✓ Ready in 73ms
Error: 'sharp' is required to be installed in standalone mode for the image optimization to function correctly. Read more at: https://nextjs.org/docs/messages/sharp-missing-in-production
Error: 'sharp' is required to be installed in standalone mode for the image optimization to function correctly. Read more at: https://nextjs.org/docs/messages/sharp-missing-in-production
...3 Replies
Standard Schnauzer
use sharp @ 3.2.6 to get rid of this error
I've tested multiple solutions and none worked with sharp @ 3.3.0
Atlantic menhaden
I am having this problem too, just a note to say that changing to sharp@0.32.6 has fixed it for now rather than @ 3.2.6