Netlify changing base directory to /opt/build/repo always

My build settings:
Screenshot 2023-01-05 at 10.36.39 AM

Then when building the build bot ignores that it should stay in the base directory entirely:

10:09:21 AM: ❯ Current directory
10:09:21 AM: /opt/build/repo

Then obviously an error occurs when it cannot find the production files in a directory that I haven’t specified should exist:

Error: The directory “/opt/build/repo/dist/packages/dam-web” does not contain a Next.js production build. Perhaps the build command was not run, or you specified the wrong publish directory.

The build is failing because the build bot does not stay in the base directory as I have specified in the build settings, it instead goes to /opt/build/repo/dist/packages/dam-web to look for a production build, which does not exist, because I have specified my output directory as only /dist/packages/dam-web from the base directory. What am I missing that makes the build bot ignore my build settings?

Hi @NoFo, welcome and thanks for the post.

Based on the quoted error above I am assuming your site is a Next.js site.

The typical build settings are as follows. They differ depending on how your site is generated.

  • For apps that use server-side rendering and Next.js Runtime:
    • Build command: next build
    • Publish directory: .next
  • For apps that use static HTML export:
    • Build command: next build && next export
    • Publish directory: out

Kindly try the above and let me know the outcome.


Thanks for the Tips @clarnx I appreciate it. @NoFo please let us know if you this helps by marking it as the solution. Good luck. :slight_smile:

1 Like