@netlify/plugin-nextjs plugin failed

Getting error on deploy of a Nextjs site:

Plugin "@netlify/plugin-nextjs" failed

Error: The directory "out" does not contain a Next.js production build. Perhaps the build command was not run, or you specified the wrong publish directory. Your publish directory is set to "out", but in most cases it should be ".next". If you are using "next export" then the Essential Next.js plugin should be removed. See https://ntl.fyi/remove-plugin for details.

In "onBuild" event in "@netlify/plugin-nextjs" from Netlify app at Object.checkNextSiteHasBuilt (/.netlify/plugins/node_modules/@netlify/plugin-nextjs/lib/helpers/verification.js:67:16) at onBuild (/.netlify/plugins/node_modules/@netlify/plugin-nextjs/lib/index.js:24:24)

I’ve deployed a couple other Next.js sites the same way without issue. Any idea whats wrong all of a sudden?

Hi @zhitch

Have you tried changing the publish directory from out to .next?

Also note this message, if you are using next export, then you should remove @netlify/plugin-nextjs.

Okay, changing the publish directory to .next werked. Did something change? Why wouldn’t out work anymore?

The plugin is now at v4 (see release notes) and has more support for core Next.js functionality (such as ISR) and as such the change in publish directory was required.

out is still used, by only if using next export to build a static site.

1 Like

Very well, makes sense. Thanks for the info, makes me feel like I’m not going insane by doing something that worked previously and then doesn’t.

1 Like