I’m encountering an issue while deploying my Next.js project on Vercel. The build process fails with the following error:
Creating an optimized production build ...
uncaughtException RangeError: Invalid array length
at Array.push (<anonymous>)
Error: Command "npm run build" exited with 1
I’ve tried the following troubleshooting steps but haven’t found a solution:
Cleared .next and node_modules, then reinstalled dependencies
Checked for any infinite loops or excessive recursion in my code
Ran npm run build locally, which works fine without errors
Hi @mikky15, sorry that you’re facing this issue. Is this a v0 created project? Can you share more information about what you’re doing the project and since when this error started popping?
Since you said npm run build works, do you only see the error on Vercel?
The error first started appearing on March 15th, 2025, after I made some changes to the code and tried deploying it to Vercel. I’m only encountering the error during deployment on Vercel, while the npm run build command works fine on my local machine.
Please let me know if you need any additional information to help troubleshoot!
Hi @mikky15, thanks for the information but without looking at the code it’s hard to debug this error. Can you please share your public repo or a minimal reproducible example. That will let us all work together from the same code to figure out what’s going wrong.