What it means
Node.js limits how much memory a process can use. During your build, a step grew past that limit and stopped. This usually means a very large bundle: many files, large images imported as code, or a package pulled in that does not need to be.
How to fix it
-
Remove what you do not need
Look for a large dependency that is imported only for one small use, large data files imported into code, or a whole library imported instead of one function.
-
Raise Node's memory limit in the build script
Set
NODE_OPTIONS=--max-old-space-sizein your build script. The number is in megabytes.{ "scripts": { "build": "NODE_OPTIONS=--max-old-space-size=4096 next build" } } -
Build again
The build server has a limited amount of memory, so raising the limit only helps up to what it has. A smaller bundle is the more reliable fix.