#Error: ENOENT: no such file or directory, lstat '/vercel/path0/.next/export-detail.json'

10 messages · Page 1 of 1 (latest)

timber river
#

I am trying to deploy my repo to Vercel and I got this error at the end of the build log which doesn't provide me any more details:
Error: ENOENT: no such file or directory, lstat '/vercel/path0/.next/export-detail.json'

I had a similar situation with this reddit post but this didn't work either (update):
https://www.reddit.com/r/nextjs/comments/1bkswd8/enoent_no_such_file_or_directory_lstat/

Any reason why this is happening?
This is my repo:
https://github.com/ubergonmx/porum-nextjs

Reddit

Explore this post and more from the nextjs community

GitHub

A simple forum made in NextJS. Contribute to ubergonmx/porum-nextjs development by creating an account on GitHub.

strong hearthBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

exotic sable
#

This error indicates a missing file export-detail.json in .next directory. This issue typically arises during the static export process when Vercel expects certain files to exist but they haven't been generated or are missing.

timber river
#

How do I fix this? It doesn't generate export-detail.json even if I run npm run build locally

exotic sable
#

Start another project and copy all your folders

timber river
exotic sable
#

can u show more logs?

timber river
timber river
timber river
#

I found the issue and that is import { writeFile as fsWriteFile } from "fs/promises"; in my server actions file.

For more context, I had the following:

let url: string | undefined;
if (avatar) {
  if (env.STORAGE === "local") {
    url = `${Date.now()}-${generateIdFromEntropySize(5)}-${avatar.name.replaceAll(" ", "_")}`;
    const buffer = Buffer.from(await avatar.arrayBuffer());
    const fullPath = process.cwd() + "/" + env.LOCAL_AVATAR_PATH + url;
    await fsWriteFile(fullPath, buffer);

    console.log("[SIGNUP] Avatar saved to", fullPath);
  } else if (env.STORAGE === "online") {
    const [res] = await uploadFiles("avatar", {
      files: [avatar],
    });
    url = res.url;
  }
}

Reason is that you can't write files in Serverless Functions because the file system is ephemeral.
I commented it when deploying, only added a note to uncomment it if they want to test locally the avatar saving.
Sources:

Reddit

Explore this post and more from the nextjs community

GitHub

I'm trying to read/write to a known folder in my app. It works on my local machine because I created the folder. How do I create such a folder on a deployed app? Thanks. To clarify. I can check...