Next.js Discord

Discord Forum

Error occurred prerendering page "/_not-found"

Unanswered
andrei posted this in #help-forum
Open in Discord
info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/app/api-reference/config/eslint#disabling-rules
 ✓ Linting and checking validity of types 
 ✓ Collecting page data    
Error occurred prerendering page "/_not-found". Read more: https://nextjs.org/docs/messages/prerender-error
ReferenceError: window is not defined
    at 49882 (D:\mathbits-next\.next\server\chunks\60.js:2:92532)
    at t (D:\mathbits-next\.next\server\webpack-runtime.js:1:143)
    at 56349 (D:\mathbits-next\.next\server\chunks\712.js:13:999)
    at Object.t [as require] (D:\mathbits-next\.next\server\webpack-runtime.js:1:143)
    at require (D:\mathbits-next\node_modules\.pnpm\next@15.3.1_react-dom@18.3.1_react@18.3.1__react@18.3.1\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:140:10304)
    at u (D:\mathbits-next\node_modules\.pnpm\next@15.3.1_react-dom@18.3.1_react@18.3.1__react@18.3.1\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:92:646)
    at U (D:\mathbits-next\node_modules\.pnpm\next@15.3.1_react-dom@18.3.1_react@18.3.1__react@18.3.1\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:92:10632)
    at T (D:\mathbits-next\node_modules\.pnpm\next@15.3.1_react-dom@18.3.1_react@18.3.1__react@18.3.1\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:92:8681)
    at rM (D:\mathbits-next\node_modules\.pnpm\next@15.3.1_react-dom@18.3.1_react@18.3.1__react@18.3.1\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:76:33176)
    at nW (D:\mathbits-next\node_modules\.pnpm\next@15.3.1_react-dom@18.3.1_react@18.3.1__react@18.3.1\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:76:65533)
Export encountered an error on /_not-found/page: /_not-found, exiting the build.
 ⨯ Next.js build worker exited with code: 1 and signal: null
 ELIFECYCLE  Command failed with exit code 1.


What's this caused by? I am only trying to render my app fully static

1 Reply

The error trace says you're trying to use the window object, can you confirm?
You can only access the window object exclusively on the client, so either use it inside an Effect, an event handler or in a client component that has SSR disabled.