Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

846
Views
Strange next.js error in production: ENOENT: No such file or directory (image cache)

I'm having issues with my next.js deployment on AWS EC2. I npm run build and then npm run start, and it works fine. At that point, there are no webp images in the cache, as expected. Then I load the webpage from my browser ,and it works fine. However it randomly seems to crash when i load the page sometimes. And i get the error above. It seems like the webp image is being deleted from the cache at some point, and causing an error? Any suggestions?

The full error is:

Error: ENOENT: no such file or directory, open '/home/ec2-user/prowash/pro-wash-site/.next/cache/images/7P-NdCEO6XWRTvqPItIV6CN1db-7IkBJw9kp3M5VafQ=/0.1647390677641.UEF7UxgKHha+us8b5ahYFWZH70qZHTAu2uyVPlYT7Hs=.webp'
Emitted 'error' event on ReadStream instance at:
    at emitErrorNT (node:internal/streams/destroy:164:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/home/ec2-user/prowash/pro-wash-site/.next/cache/images/7P-NdCEO6XWRTvqPItIV6CN1db-7IkBJw9kp3M5VafQ=/0.1647390677641.UEF7UxgKHha+us8b5ahYFWZH70qZHTAu2uyVPlYT7Hs=.webp'
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Perhaps use a build script to set the permissions and then implement the next build.

Modifying the solution for EBS via this article:

  1. A Build.sh script that sets permissions before its deployed
#!/bin/bash

# Exit immediately if a command exits with a non-zero status
set -e


# building the Next.js application
npm run next:build

# creating the build/cache/images folder and give it
# the read/write permissions
mkdir -p .next/cache/images
chmod -R 666 .next/cache/images
  1. Addition to package.json to make sure it runs on npm run build
"scripts": {
  "build": "./build.sh"
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!