Tengo problemas con mi implementación de next.js en AWS EC2. npm run build y luego npm run start , y funciona bien. En ese momento, no hay imágenes webp en el caché, como se esperaba. Luego cargo la página web desde mi navegador y funciona bien. Sin embargo, parece fallar al azar cuando cargo la página a veces. Y me sale el error de arriba. Parece que la imagen webp se está eliminando del caché en algún momento y está causando un error. ¿Alguna sugerencia?
El error completo es:
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' }Tal vez use un script de compilación para establecer los permisos y luego implementar la siguiente compilación.
Modificando la solución para EBS a través de este artículo :
#!/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/imagespackage.json para asegurarse de que se ejecuta en npm run build "scripts": { "build": "./build.sh" }