DEV Community

Empty Stack
Empty Stack

Posted on

ReferenceError while deploying NextJS frontend on Vercel?

I am trying to deploy my website on Vercel but I am facing this error at the build time. This error occurs during preredering of the page
ReferenceError: document is not defined
at createTag (/vercel/path0/.next/server/chunks/9869.js:151:25622)
at /vercel/path0/.next/server/chunks/9869.js:151:38510
at /vercel/path0/.next/server/chunks/9869.js:151:38633
at /vercel/path0/.next/server/chunks/9869.js:151:41458
at /vercel/path0/.next/server/chunks/9869.js:151:25287
at 60496 (/vercel/path0/.next/server/chunks/9869.js:151:25291)
at t (/vercel/path0/.next/server/webpack-runtime.js:1:143)
at 88924 (/vercel/path0/.next/server/chunks/9869.js:152:58908)
at t (/vercel/path0/.next/server/webpack-runtime.js:1:143)
at 85912 (/vercel/path0/.next/server/chunks/5708.js:34:11987)
Generating static pages (13/18)
ReferenceError: document is not defined
at createTag (/vercel/path0/.next/server/chunks/9869.js:151:25622)
at /vercel/path0/.next/server/chunks/9869.js:151:38510
at /vercel/path0/.next/server/chunks/9869.js:151:38633
at /vercel/path0/.next/server/chunks/9869.js:151:41458
at /vercel/path0/.next/server/chunks/9869.js:151:25287
at 60496 (/vercel/path0/.next/server/chunks/9869.js:151:25291)
at t (/vercel/path0/.next/server/webpack-runtime.js:1:143)
at 88924 (/vercel/path0/.next/server/chunks/9869.js:152:58908)
at t (/vercel/path0/.next/server/webpack-runtime.js:1:143)
at 85912 (/vercel/path0/.next/server/chunks/5708.js:34:11987) {
digest: '2326889752'
}

I have this error in all these files:

Export encountered errors on following paths:
/Contact/page: /Contact
/_not-found/page: /_not-found
/admin/UnasssignedByWorker/page: /admin/UnasssignedByWorker
/admin/reports/page: /admin/reports
/admin/verify_worker/page: /admin/verify_worker
/login/page: /login
/page: /
/register/page: /register
/user/User_Profile/page: /user/User_Profile
/user/create_request/page: /user/create_request
/user/hire/page: /user/hire
/user/view_request/page: /user/view_request
/worker/all_request/page: /worker/all_request
/worker/hire/page: /worker/hire
/worker/requests/page: /worker/requests

Can anyone please tell me what is this error stating and how to resolve it? I have not used the term document in any of the files in which I have this error I am using NextJS version 14.2.8 also I am using the app directory

stack overflow link of the questionplease help i am stuck heere

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (2)

Collapse
 
alexanderdrummond profile image
Alexander Drummond

You're most likely trying to use the document object during server-side rendering. If you need an elaboration, write me a comment here :)

Collapse
 
empty_stack_752f9534b94c9 profile image
Empty Stack

I haven't defined document anywhere in the code

👋 Kindness is contagious

If you found this post useful, please drop a ❤️ or leave a kind comment!

Okay