I have a Next JS (+React) app. And I am getting the following error on the “Deploy” stage:
Deploy did not succeed: Deploy directory ".next" does not exist
I was having troubles with the build stage because Netlify was using Node 16. In the process of debugging that error, I referred to a couple of other Netlify answers and had updated my Publish directory value twice.
One time I updated it to be: build
and the second time, I updated it to be out
.
This was from “Build & Deploy” > “Continuous deployment” > “Build settings”.
That error was fixed as I set the Environment Variable NODE_VERSION
to 18
.
I have since updated the Publish directory value back to .next
(which I believe is Next’s default publish dir). But I am still getting the following error log:
4:39:05 PM: Deploy site
4:39:05 PM: ────────────────────────────────────────────────────────────────
4:39:05 PM:
4:39:05 PM: Section completed: deploying
4:39:05 PM:
4:39:05 PM: Configuration error
4:39:05 PM: ────────────────────────────────────────────────────────────────
4:39:05 PM:
4:39:05 PM: Error message
4:39:05 PM: Deploy did not succeed: Deploy directory ".next" does not exist
4:39:05 PM:
4:39:05 PM: Resolved config
4:39:05 PM: build:
4:39:05 PM: environment:
4:39:05 PM: - NETLIFY_NEXT_PLUGIN_SKIP
4:39:05 PM: - NODE_VERSION
4:39:05 PM: publish: /opt/build/repo/.next
4:39:05 PM: publishOrigin: ui
4:39:05 PM: plugins:
4:39:05 PM: - inputs: {}
4:39:05 PM: origin: ui
4:39:05 PM: package: "@netlify/plugin-nextjs"
4:39:05 PM: - inputs: {}
4:39:05 PM: origin: ui
4:39:05 PM: package: "@netlify/plugin-lighthouse"
4:39:06 PM: Failed during stage "building site": Build script returned non-zero exit code: 2
4:39:06 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:39:06 PM: Failing build: Failed to build site