A build that works on your machine and dies everywhere else is a special kind of frustrating. That was my week when a Next.js project started failing during next build with an out of memory error.
The first instinct is to blame your own code. Sometimes that is right. This time it was not. The build was simply asking for more memory than Node was allowed to use by default. Once a project gets big enough, the default heap size stops being enough, and Node gives up partway through the build.
The fix was to raise the memory ceiling Node runs with, by setting the max old space size option through NODE_OPTIONS in the build script. After that, the build finished cleanly.
What I took from it: not every build failure is a bug in your code. Some are limits in the tools around your code, and those limits have their own settings. Knowing the difference saves hours. I used to assume every error pointed back at something I wrote. Now I check whether the environment itself is the thing that ran out of room.