Cannot build my next.js app on netlify

Hi,

I’m getting an issue building my next.js site

It’s crashing in the middle of the generation, I have no idea what’s happening, I don’t have any stack trace.

You can access it from there:

Source code is there:

Currently it’s a very basic out of the box next js site.
It seems to crash when building the side I have no idea what’s happening, I don’t have any stack trace.
How can I troubleshoot it ?

4:27:04 PM: Build command from Netlify app
4:27:04 PM: ────────────────────────────────────────────────────────────────
4:27:04 PM: ​
4:27:04 PM: $ yarn build
4:27:05 PM: - warn No build cache found. Please configure build caching for faster rebuilds. Read more: No Cache Detected | Next.js
4:27:05 PM: - info Creating an optimized production build…
4:27:10 PM: - info Compiled successfully
4:27:10 PM: - info Linting and checking validity of types…
4:27:11 PM: - info Collecting page data…
4:27:18 PM: ​
4:27:18 PM: “build.command” failed
4:27:18 PM: ────────────────────────────────────────────────────────────────
4:27:18 PM: ​
4:27:18 PM: Error message
4:27:18 PM: Command failed with exit code 1: yarn build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
4:27:18 PM: ​
4:27:18 PM: Error location
4:27:18 PM: In Build command from Netlify app:
4:27:18 PM: yarn build
4:27:18 PM: ​
4:27:18 PM: Resolved config
4:27:18 PM: build:
4:27:18 PM: command: yarn build
4:27:18 PM: commandOrigin: ui
4:27:18 PM: environment:
4:27:18 PM: - NEXT_PRIVATE_TARGET
4:27:18 PM: publish: /opt/build/repo/.next
4:27:18 PM: publishOrigin: ui
4:27:18 PM: plugins:
4:27:18 PM: - inputs: {}
4:27:18 PM: origin: ui
4:27:18 PM: package: “@netlify/plugin-nextjs”
4:27:20 PM: Failed during stage “building site”: Build script returned non-zero exit code: 2
4:27:20 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:27:20 PM: Failing build: Failed to build site
4:27:20 PM: Finished processing build request in 46.718s

Hi @flegall,

Thanks for reaching out! Welcome to Netlify’s Support Forums!

I believe the issue may be with the build command, could you make the following change here:

Build command: yarn build

to

Build command: yarn run build

After making the change, please try to redeploy and let us know if you have any questions.