Basic NextJs website failing to build with exit code 129

I have been trying to deploy my lab’s website, but for some reason, the build command fails with exit code 129.

Link to repo

Log
4:20:17 PM: Netlify Build                                                 
4:20:17 PM: ────────────────────────────────────────────────────────────────
4:20:17 PM: ​
4:20:17 PM: ❯ Version
4:20:17 PM:   @netlify/build 29.47.1
4:20:17 PM: ​
4:20:17 PM: ❯ Flags
4:20:17 PM:   baseRelDir: true
4:20:17 PM:   buildId: 66694c0e6787620008824e64
4:20:17 PM:   deployId: 66694c0e6787620008824e66
4:20:17 PM: ​
4:20:17 PM: ❯ Current directory
4:20:17 PM:   /opt/build/repo
4:20:17 PM: ​
4:20:17 PM: ❯ Config file
4:20:17 PM:   No config file was defined: using default values.
4:20:17 PM: ​
4:20:17 PM: ❯ Context
4:20:17 PM:   deploy-preview
4:20:18 PM: ​
4:20:18 PM: ❯ Using Next.js Runtime - v5.3.2
4:20:19 PM: No Next.js cache to restore
4:20:19 PM: ​
4:20:19 PM: Build command from Netlify app                                
4:20:19 PM: ────────────────────────────────────────────────────────────────
4:20:19 PM: ​
4:20:19 PM: $ yarn run build
4:20:21 PM: ⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
4:20:21 PM:    ▲ Next.js 14.1.1
4:20:21 PM:    Creating an optimized production build ...
4:20:33 PM:  ✓ Compiled successfully
4:20:33 PM:    Linting and checking validity of types ...
4:20:36 PM:    Collecting page data ...
4:21:30 PM: ​
4:21:30 PM: "build.command" failed                                        
4:21:30 PM: ────────────────────────────────────────────────────────────────
4:21:30 PM: ​
4:21:30 PM:   Error message
4:21:30 PM:   Command failed with exit code 129: yarn run build (https://ntl.fyi/exit-code-129)
4:21:30 PM: ​
4:21:30 PM:   Error location
4:21:30 PM:   In Build command from Netlify app:
4:21:30 PM:   yarn run build
4:21:30 PM: ​
4:21:30 PM:   Resolved config
4:21:30 PM:   build:
4:21:30 PM:     command: yarn run build
4:21:30 PM:     commandOrigin: ui
4:21:30 PM:     environment:
4:21:30 PM:       - REVIEW_ID
4:21:30 PM:     publish: /opt/build/repo/.next
4:21:30 PM:     publishOrigin: ui
4:21:30 PM:   plugins:
4:21:30 PM:     - inputs: {}
4:21:30 PM:       origin: ui
4:21:30 PM:       package: '@netlify/plugin-nextjs'
4:21:34 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:21:38 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
4:21:38 PM: Failing build: Failed to build site
4:21:39 PM: Finished processing build request in 1m41.677s

I have tried setting the following environment variables in the Netlify UI but the error still persists:

  • NODE_VERSION to 20.14.0
  • YARN_VERSION to 4.0.2
  • NODE_ENV to --max-old-space-size=4096

I managed to build this website on Vercel and on my local machine, so the problem definitely has something to do with Netlify’s build environment. The sporadic information I could find online hints at an out-of-memory issue, but I don’t think that’s the case since this website is quite small and basic.

Your build went over the 11 GB memory limit:

You can try setting:

experimental: {
  cpus: 1
}

in your next.config.js to reduce memory usage.

Thanks for the heads up!
May I ask how you managed to profile the build process?

Adding

const nextConfig = {
  experimental: {
    cpus: 1,
  },
}

to next.config.js and also changing nodeLinker: pnp to nodeLinker: node-modules in .yarnrc.yml helped complete the build process, but the deploy preview now crashes.

The graph is from our internal logs. As for the deploy preview crashing, that doesn’t seem to happen. Has that been resovled?