Site ID: be0e2156-2b30-4482-8ff8-bbb9378bc355
When deploying an empty Next.js project that within NX mono repo, the deploying step keep fails because of this error:
7:53:09 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
7:53:09 PM: The function exceeds the maximum size of 250 MB
7:53:04 PM: Deploy site
7:53:04 PM: ────────────────────────────────────────────────────────────────
7:53:04 PM:
7:53:04 PM: Starting to deploy site from 'apps/org/.next'
7:53:04 PM: Calculating files to upload
7:53:05 PM: 0 new file(s) to upload
7:53:05 PM: 1 new function(s) to upload
7:53:09 PM: Failed to upload file: ___netlify-server-handler
7:53:09 PM: Section completed: deploying
7:53:09 PM:
7:53:09 PM: Error deploying
7:53:09 PM: ────────────────────────────────────────────────────────────────
7:53:09 PM:
7:53:09 PM: Error message
7:53:09 PM: Deploy did not succeed with HTTP Error 400: [PUT /deploys/{deploy_id}/functions/{name}][400] uploadDeployFunction default &{Code:400 Message:The function exceeds the maximum size of 250 MB}
7:53:09 PM:
7:53:09 PM: Error location
7:53:09 PM: At deploy the stage with HTTP status code '400'
7:53:09 PM:
7:53:09 PM: Resolved config
7:53:09 PM: build:
7:53:09 PM: command: nx run @org/org:build
7:53:09 PM: commandOrigin: ui
7:53:09 PM: publish: /opt/build/repo/apps/org/.next
7:53:09 PM: publishOrigin: ui
7:53:09 PM: headers:
7:53:09 PM: - for: /_next/static/*
values:
Cache-Control: public, max-age=31536000, immutable
headersOrigin: inline
plugins:
- inputs: {}
origin: ui
package: "@netlify/plugin-nextjs"
redirects:
- from: /_next/image
query:
q: :quality
url: :url
w: :width
status: 200
to: /.netlify/images?url=:url&w=:width&q=:quality
- from: /_ipx/*
query:
q: :quality
url: :url
w: :width
status: 200
to: /.netlify/images?url=:url&w=:width&q=:quality
redirectsOrigin: inline
7:53:09 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
7:53:09 PM: Failing build: Failed to build site
I’m using:
- Nx@21.2.2
- Next.js@15
Steps:
- Init new Nx workspace
npx create-nx-workspace@latest
- Create a Next.js app using Nx generator
- Upload to GitHub repo
- Connect that repo to new Netlify site