title: Deploy did not succeed: Deploy directory 'out' does not exist
body: <p>When deploying an app created with Next.js to netlify, the following error occurs and the deployment fails.</p>
  <pre><code>────────────────────────────────────────────────────────────────
    6. Deploy site                                                
  ────────────────────────────────────────────────────────────────
  ​
  ​
  ────────────────────────────────────────────────────────────────
    Configuration error                                           
  ────────────────────────────────────────────────────────────────
  ​
    Error message
    Deploy did not succeed: Deploy directory 'out' does not exist
  ​
    Resolved config
    build:
      command: yarn build
      commandOrigin: config
      publish: /opt/build/repo/out
    plugins:
      - inputs: {}
        origin: config
        package: '@netlify/plugin-nextjs'
      - inputs: {}
        origin: config
        package: netlify-plugin-cache-nextjs
  Caching artifacts
  Started saving node modules
  Finished saving node modules
  Started saving build plugins
  Finished saving build plugins
  Started saving yarn cache
  Finished saving yarn cache
  Started saving pip cache
  Finished saving pip cache
  Started saving emacs cask dependencies
  Finished saving emacs cask dependencies
  Started saving maven dependencies
  Finished saving maven dependencies
  Started saving boot dependencies
  Finished saving boot dependencies
  Started saving rust rustup cache
  Finished saving rust rustup cache
  Started saving go dependencies
  Finished saving go dependencies
  Build failed due to a user error: Build script returned non-zero exit code: 2
  Failing build: Failed to build site
  Failed during stage 'building site': Build script returned non-zero exit code: 2
  Finished processing build request in 1m25.310488139s
  </code></pre>
  <p>The various files and settings are shown below.</p>
  <p><strong>netlify.toml</strong></p>
  <pre><code>[build]
    command = &quot;yarn build&quot;
    publish = &quot;out&quot;
  
  [[plugins]]
    package = &quot;@netlify/plugin-nextjs&quot;
  
  [[plugins]]
    package = &quot;netlify-plugin-cache-nextjs&quot;
  </code></pre>
  <p><strong>package.json</strong></p>
  <pre class="lang-json prettyprint-override"><code>...
  &quot;scripts&quot;: {
    &quot;dev&quot;: &quot;next&quot;,
    &quot;build&quot;: &quot;next build&quot;,
    &quot;start&quot;: &quot;next start&quot;,
    &quot;export&quot;: &quot;next export&quot;
  },
  ...
  </code></pre>
  <p><strong>Netlify | Build settings</strong><br />
  <a href="https://i.stack.imgur.com/rpdko.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/rpdko.jpg" alt="congif" /></a></p>
  <p>The various settings are based on the following pages.</p>
  <ul>
  <li><a href="https://community.netlify.com/t/failed-during-stage-building-site-deploy-directory-out-does-not-exist/30986/10" rel="noreferrer">Failed during stage 'building site': Deploy directory 'out' does not exist - Support - Netlify Community</a></li>
  <li><a href="https://docs.netlify.com/configure-builds/common-configurations/next-js/?_ga=2.167785641.929602931.1614175758-1995773659.1608391628" rel="noreferrer">Next.js on Netlify | Netlify Docs</a></li>
  </ul>
  <p>If you know how to solve this problem, please let me know.<br />
  I'm open to any ideas.</p>