What it means
next build does its heavy work in a separate worker process. When that process crashes, Next.js reports only the exit code. It does not name the cause in this line. The cause is in the lines just above it.
How to fix it
-
Read the lines above the message
They normally quote the file that was being compiled, or a thrown error. That file is the place to start. Your agent can read the build log from the deploy history.
-
Run the same build on your machine
Run
npm run buildlocally. If it fails there too, fix that error first. If it passes, the cause is the environment, so continue below. -
Check memory on a large project
A large project can run the build out of memory. Look for a dependency that is pulled in and does not need to be, or very large files in the bundle.
Common causes
-
A thrown error in a route or component. The error is printed above the exit code.
-
A variable read at import time. See Failed to collect page data.
-
Out of memory. See JavaScript heap out of memory.
-
A type error. See TypeScript errors fail the build.