Build Works Fine locally but not on vercel
Answered
Glossy Ibis posted this in #help-forum
Glossy IbisOP
i get the error:
when i try to build on vercel but when i try it locally its fine and builds without any issue?
why is that so?
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
ReferenceError: document is not defined
at createTag (/vercel/path0/.next/server/app/page.js:1:243236)
at /vercel/path0/.next/server/app/page.js:1:256107
at /vercel/path0/.next/server/app/page.js:1:256230
at /vercel/path0/.next/server/app/page.js:1:259025
at /vercel/path0/.next/server/app/page.js:1:242901
at 3104 (/vercel/path0/.next/server/app/page.js:1:242905)
at t (/vercel/path0/.next/server/webpack-runtime.js:1:128)
at 8387 (/vercel/path0/.next/server/app/page.js:9:62687)
at Object.t [as require] (/vercel/path0/.next/server/webpack-runtime.js:1:128)
at require (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:140:10304)
Export encountered an error on /page: /, exiting the build.
⨯ Next.js build worker exited with code: 1 and signal: null
Error: Command "npm run build" exited with 1
when i try to build on vercel but when i try it locally its fine and builds without any issue?
why is that so?
Answered by Glossy Ibis
Alright i found the answer:
i had lottie-react, i just had to import it dynamically:
dk why it got build locally tho
i had lottie-react, i just had to import it dynamically:
import dynamic from "next/dynamic";
const Lottie = dynamic(() => import("lottie-react"), { ssr: false });
dk why it got build locally tho
1 Reply
Glossy IbisOP
Alright i found the answer:
i had lottie-react, i just had to import it dynamically:
dk why it got build locally tho
i had lottie-react, i just had to import it dynamically:
import dynamic from "next/dynamic";
const Lottie = dynamic(() => import("lottie-react"), { ssr: false });
dk why it got build locally tho
Answer