Error: ENOENT: no such file or directory, lstat '/vercel/path0/.next/export-detail.json'
Answered
P𝑠eudo posted this in #help-forum
P𝑠eudoOP
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:
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
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
Answered by P𝑠eudo
I found the issue and that is
For more context, I had the following:
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:
- https://github.com/orgs/vercel/discussions/241#discussioncomment-363002
- https://www.reddit.com/r/nextjs/comments/zo5ez3/creating_a_file_using_fs_on_vercel/
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:
- https://github.com/orgs/vercel/discussions/241#discussioncomment-363002
- https://www.reddit.com/r/nextjs/comments/zo5ez3/creating_a_file_using_fs_on_vercel/
8 Replies
Japanese jack mackerel
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.
P𝑠eudoOP
How do I fix this? It doesn't generate export-detail.json even if I run
npm run build
locallyJapanese jack mackerel
Start another project and copy all your folders
Japanese jack mackerel
can u show more logs?
@Japanese jack mackerel can u show more logs?
P𝑠eudoOP
I don't know what to get from these logs, the error doesn't make any sense to me.
P𝑠eudoOP
I found the issue and that is
For more context, I had the following:
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:
- https://github.com/orgs/vercel/discussions/241#discussioncomment-363002
- https://www.reddit.com/r/nextjs/comments/zo5ez3/creating_a_file_using_fs_on_vercel/
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:
- https://github.com/orgs/vercel/discussions/241#discussioncomment-363002
- https://www.reddit.com/r/nextjs/comments/zo5ez3/creating_a_file_using_fs_on_vercel/
Answer