Next.js Discord

Discord Forum

"The directory "/opt/build/repo/.next" does not contain a Next.js production build"

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
Hi all, I've been stuck on this for a few days. I'm deploying on Netlify mostly with the help of ChatGPT (newbie "programmer" trying to build a web-based tool for personal use) and I keep getting the following error. Prior to using Next.js and fetching data, the deployment worked well.

9:51:32 PM: Plugin "@netlify/plugin-nextjs" failed
9:51:32 PM: ────────────────────────────────────────────────────────────────
9:51:32 PM: ​
9:51:32 PM: Error message
9:51:32 PM: Error: The directory "/opt/build/repo/.next" does not contain a Next.js production build. Perhaps the build command was not run, or you specified the wrong publish directory.
9:51:32 PM: In most cases it should be set to ".next", unless you have chosen a custom "distDir" in your Next config.
9:51:32 PM: If you are using "next export" then you should set the environment variable NETLIFY_NEXT_PLUGIN_SKIP to "true".

I tried many things (including starting new repository with an original Next.js template but even that crashes).

I tried updating versions to make sure they interact well (can share package.json text if needed) but even that failed.

Do I understand correctly that I should just deploy elsewhere? Is Netlify too limited? Thank you so much and please let me know if you have other questions.

1 Reply

did you try doing anything mentioned in the error message?