Failed to write Error: ENOENT. How to solve and understand this error?! #56690
Replies: 5 comments
-
Found the solution to this matter: I added this part:
Edit: |
Beta Was this translation helpful? Give feedback.
-
Maybe create an empty cache folder during build will fix it? |
Beta Was this translation helpful? Give feedback.
-
did you try RUN mkdir -p .next/cache
RUN chown -R nextjs:nodejs .next after |
Beta Was this translation helpful? Give feedback.
-
I am using
RESOLVED My application is running on AWS Fargate with Here is my # turborepo where apps/product-web is an nextjs application
# production-web: NextJs application
FROM node:20-bookworm-slim AS web-runner
# Create a shop user to run the app
RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 --home /home/shop --shell /bin/bash shop \
&& mkdir -p /app && chown -R shop:nodejs /app
WORKDIR /app
ARG ENVIRONMENT
ENV PORT 3000
ENV NODE_ENV=production
# Copy all needed for nextjs production
COPY --chown=shop:nodejs --from=installer /app/apps/product-web/.next/standalone ./
COPY --chown=shop:nodejs --from=installer /app/node_modules/sharp node_modules/sharp
# Use /tmp/next/cache for storeing all caching
RUN mkdir -p /tmp/next/cache \
&& chown shop:nodejs /tmp/next/cache \
&& ln -s /tmp/next/cache /app/apps/product-web/.next/cache
USER shop
EXPOSE $PORT
ENV HOSTNAME 0.0.0.0
# I have a custom script to start nodejs
RUN chmod +x scripts/startup-web.sh
ENTRYPOINT ["sh", "-c", "scripts/startup-web.sh"] |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm getting this error using nextjs 14.2.29
did you get a workaround? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I have a nextjs@latest application that runs perfectly locally. And in production.
But on the nodeServer I see these errors from time to time.
Failed to write image to cache 0g-agIzWCv1tkoUXVScWsNPsotuhEaMDFJat8K6khOg= [Error: ENOENT: no such file or directory, mkdir '/app/.next/cache'] {errno: -2,code: 'ENOENT',syscall: 'mkdir',path: '/app/.next/cache'}
My thought is to copy the cache folder during the docker build, good idea?

Additional information
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions