Henrik VT
Henrik VT

Reputation: 533

NextJS on Netlify: Deploy did not succeed; Deploy directory 'out' does not exist

I am currently developing a website and am hosting it on Netlify. Up until a recent change, It has been deploying with no issues. However, I pushed a change and suddenly, I get this error; Deploy did not succeed: Deploy directory 'out' does not exist. I know that there are many similar questions on here and other forums, but I have tried those solutions and their combinations with no success.
Sources that I viewed:

Here is the GitHub repository: https://github.com/henrikvtcodes/henrikvt.com-nextjs-old
Things I have tried:

All of these have either failed with the aforementioned error code or exit code 1.

I have no idea what to do. The standard npm run build command runs perfectly fine on my local system as well. Another piece of potentially useful information; I test-deployed the same repository on Vercel and that worked perfectly (somewhat as expected) but I'd rather use Netlify for multiple reasons.

Upvotes: 2

Views: 2340

Answers (1)

Lingertje
Lingertje

Reputation: 236

When you have a next.config.js add target: serverless to it. The file will look something like this:

// next.config.js
module.exports = {
  future: {
    webpack5: true,
  },
  target: 'serverless'
}

What you can then do is add a netlify.toml file to the root of your project to tell Netlify it should run the build command like so:

// netlify.toml
[build]
  command = "yarn build"

This made my Next.js deploys to Netlify work.

Upvotes: 4

Related Questions