Hi,
I recently upgraded my project from Next.js 14 to 15. While I can run it without any issues locally — both in dev mode and serving a local production build — it works perfectly fine with no errors.
However, when I deploy it on Netlify, the function crashes and I get the following error in the logs. I’ve checked my code thoroughly and cannot find anywhere I might have missed adding "use client". Even the component contained in chunk 5059 is lazy-loaded.
At this point I’m running out of patience. I may need to test the same deployment on Vercel to see if the issue is specific to Netlify’s environment.
Could you please advise on what might be causing this difference in behavior between local and Netlify?
Thanks
Aug 8, 05:54:12 PM: 87621f83 ERROR Unhandled Promise Rejection {“errorType”:“Runtime.UnhandledPromiseRejection”,“errorMessage”:“ReferenceError: document is not defined”,“reason”:{“errorType”:“ReferenceError”,“errorMessage”:“document is not defined”,“stack”:[“ReferenceError: document is not defined”," at cW (/var/task/apps/kids-guitar-dojo/.next/server/chunks/5059.js:347:84907)“,” at iP.load (/var/task/apps/kids-guitar-dojo/.next/server/chunks/5059.js:382:133804)“,” at iS.load (/var/task/apps/kids-guitar-dojo/.next/server/chunks/5059.js:382:135966)“,” at /var/task/apps/kids-guitar-dojo/.next/server/chunks/1940.js:1:36488"," at Array.forEach ()“,” at 54674 (/var/task/apps/kids-guitar-dojo/.next/server/chunks/1940.js:1:36473)“,” at Function.c (/var/task/apps/kids-guitar-dojo/.next/server/webpack-runtime.js:1:143)“,” at process.processTicksAndRejections (node:internal/process/task_queues:95:5)“]},“promise”:{},“stack”:[“Runtime.UnhandledPromiseRejection: ReferenceError: document is not defined”,” at process. (file:///var/runtime/index.mjs:1326:17)“,” at process.emit (node:events:536:35)“,” at emitUnhandledRejection (node:internal/process/promises:250:13)“,” at throwUnhandledRejectionsMode (node:internal/process/promises:385:19)“,” at processPromiseRejections (node:internal/process/promises:470:17)“,” at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"]}