Niels-IO / next-image-export-optimizer

Use Next.js advanced <Image/> component with the static export functionality. Optimizes all static images in an additional step after the Next.js static export.
MIT License
439 stars 52 forks source link

Error: ENOENT: no such file or directory, scandir 'remoteImagesForOptimization' #221

Closed jamesfeeder closed 3 months ago

jamesfeeder commented 3 months ago

Hello, I recently encountered a problem when deploying my website to a Cloudflare Page.

Here is the build log from that deployment:

17:29:37.657    ---- next-image-export-optimizer: Begin with optimization... ---- 
17:29:37.781    node:fs:1527
17:29:37.781      handleErrorFromBinding(ctx);
17:29:37.782      ^
17:29:37.782    
17:29:37.782    Error: ENOENT: no such file or directory, scandir 'remoteImagesForOptimization'
17:29:37.782        at Object.readdirSync (node:fs:1527:3)
17:29:37.782        at nextImageExportOptimizer (/opt/buildhome/repo/node_modules/.pnpm/next-image-export-optimizer@1.14.0_next@14.2.3_react@18.3.1/node_modules/next-image-export-optimizer/dist/optimizeImages.js:158:44) {
17:29:37.782      errno: -2,
17:29:37.782      syscall: 'scandir',
17:29:37.782      code: 'ENOENT',
17:29:37.783      path: 'remoteImagesForOptimization'
17:29:37.783    }
17:29:37.783    
17:29:37.783    Node.js v18.17.1
17:29:37.788     ELIFECYCLE  Command failed with exit code 1.
17:29:37.821    Failed: Error while executing user command. Exited with error code: 1
17:29:37.831    Failed: build command exited with code: 1
17:29:38.738    Failed: error occurred while running build command

edited: For more infomation. I did not use any remote images. I downgraded to version 1.13.0 and it fixed.

Thank you

Niels-IO commented 3 months ago

Hi @jamesfeeder,

Thank you very much for the bug report! I fixed it in #222, and I will publish a new version now.

Cheers, Niels