[Solved] Deploy did not succeed: Deploy directory 'out' does not exist

Next JS Tarif Hossain

Problem:

We deployed a nextjs site to Netlify and getting this error:

4:14:50 PM: Failed during stage ‘building site’: Deploy directory ‘out’ does not exist!


Solution 1:

You need to add

target: 'serverless'

to your next.config.js file.


Solution 2:

You can specify a name to use for a custom build directory to use instead of .next.

Open next.config.js and add the distDir config:

module.exports = {
  distDir: 'build',
}

Solution 3:

It was a simple change. In your package.json add this script "export": "next build && next export". And then change your build command to npm run export.

[build]
  command = "yarn build && yarn export"
  publish = "out"

Thank you for reading this article. If you have any opinions don't hesitate to comment here.