i made a website and im trying to run npm run build but i keep getting this error :
PS C:UsersArashDesktopvs codenexton> npm run build
> [email protected] build
> next build
▲ Next.js 14.2.3
Creating an optimized production build ...
✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
Generating static pages (0/8) [= ]ReferenceError: document is not defined
at i (C:UsersArashDesktopvs codenexton.nextserverapppage.js:1:12651)
at nj (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:46251)
at nM (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:47571)
at nM (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:61546)
at nN (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:64546)
at nB (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:67538)
at nM (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:58560)
at nN (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:64546)
at nB (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:67538)
at nD (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:66680) {
digest: '3904383914'
}
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
ReferenceError: document is not defined
at i (C:UsersArashDesktopvs codenexton.nextserverapppage.js:1:12651)
at nj (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:46251)
at nM (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:47571)
at nM (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:61546)
at nN (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:64546)
at nB (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:67538)
at nM (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:58560)
at nN (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:64546)
at nB (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:67538)
at nD (C:UsersArashDesktopvs codenextonnode_modulesnextdistcompilednext-serverapp-page.runtime.prod.js:12:66680)
✓ Generating static pages (8/8)
> Export encountered errors on following paths:
/page: /
whats the problem here ?
i tried to check the server side pages but couldnt find the propblem , next js says the poblem is from wrong document usage but i always use useEffect whenever i want to call a document
New contributor
Arash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.