dc7290 / next-export-optimize-images

Optimize images at build time with Next.js.
https://next-export-optimize-images.vercel.app
MIT License
375 stars 34 forks source link

Error logs when exporting: ENOENT No such file or directory #945

Open henrybabbage opened 3 weeks ago

henrybabbage commented 3 weeks ago

Describe the bug When running npm run build there are error messages "No such or directory, unlink." The build still completes but indicates on completion that: Cache assets: 0, NonCache assets: 2471, Error assets: 89

To Reproduce Steps to reproduce the behavior:

  1. npm run build
  2. Error logs display the following messages:
[Error: ENOENT: no such file or directory, unlink '/opt/render/project/src/out/_next/static/chunks/images/images/team/rob_2048.webp'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'unlink',
  path: '/opt/render/project/src/out/_next/static/chunks/images/images/team/rob_2048.webp'
}

Expected behavior I would just like to understand how to approach resolving this error. The error message is not entirely clear to me. This directory does exist within the codebase. And there are also image files within that directory.

Screenshots error_logs@2x

Desktop (please complete the following information):

Additional context My next.config.mjs is set up as follows:

All of the images within the codebase are stored in /public/images

/* eslint-disable @typescript-eslint/no-unsafe-call */

import createMDX from "@next/mdx";
import withExportImages from "next-export-optimize-images";
import remarkGfm from "remark-gfm";

/** @type {import('next').NextConfig} */
const nextConfig = await withExportImages({
  // Configure `pageExtensions` to include MDX files
  pageExtensions: ["js", "jsx", "mdx", "ts", "tsx"],
  // Optionally, add any other Next.js config below
  output: "export",
});

const withMDX = createMDX({
  // Add markdown plugins here, as desired
  options: {
    remarkPlugins: [remarkGfm],
    rehypePlugins: [],
  },
});

export default withMDX(nextConfig);

Many thanks in advance for any advice!

jpomykala commented 3 weeks ago

I'm getting the same issue

Versions