Fix · Node, npm and build
Error occurred prerendering page during next build
What you may see
- The build fails on one page with a prerender message
- It says window is not defined or cannot read properties of undefined
Most likely cause
While building, the page code runs on a server without a browser, and it uses browser-only things (window, localStorage) or data that is empty at build time.
Check first (about two minutes)
- Read which page is named in the error.
The fix prompt
What you type here never leaves your browser. The search runs on this page, and nothing is sent to a server or to an AI.
Kept only in this browser, on this device. Keys and passwords are removed before anything is saved.
Prompt language
Paste it into Claude, ChatGPT, Gemini or Cursor, then follow what it says.
After you tried it, did it work?
Steps
- Open that page and find the line that uses window, document, localStorage, or data that may be missing.
- Move browser-only code into an effect that runs after the page loads, or into a client-only component.
- Handle missing data with a safe default or an empty state.
Do not do this
- Do not set fake data to pass the build.
- Do not wrap the whole site in client-only mode to avoid the error.