Deploy to Vercel
Answered
Ocicat posted this in #help-forum
OcicatOP
I have a next.js projekt that works perfectly in the development mode. But wenn i want to deploy it to vercel i get the Errors: "Compiler server unexpectedly exited with code: null and signal: SIGKILL
" and "ReferenceError: location is not defined".
" and "ReferenceError: location is not defined".
Answered by Standard Chinchilla
I'm guessing this line is the problem:
Willkommen {user ? user.displayName : router.push("/sign-in")},{" "}30 Replies
Standard Chinchilla
window.location is not deffined
OcicatOP
is it just like window.location = ?
Standard Chinchilla
first check if window is defined
OcicatOP
wanna see the code?
Standard Chinchilla
typeof window != "undefinded" && (do something with location)
sure send code
OcicatOP
Standard Chinchilla
which line is broken
OcicatOP
ReferenceError: location is not defined
at /vercel/path0/.next/server/chunks/708.js:1:6107
at /vercel/path0/.next/server/chunks/708.js:1:6881
at t.startTransition (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:108548)
at Object.push (/vercel/path0/.next/server/chunks/708.js:1:6869)
at tr (/vercel/path0/.next/server/app/page.js:287:4862)
at nM (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:47419)
at nN (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64674)
at nI (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:46806)
at nM (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:47570)
at nM (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:61663)idk
in dev mode it works
Standard Chinchilla
I don't see that line in th e file you sent
location is not in the file
OcicatOP
i think its because of the next/navigation
Standard Chinchilla
you're using that fine
OcicatOP
i tried to use next/router but it doesn't work either
@Standard Chinchilla I don't see that line in th e file you sent
OcicatOP
thats all the code
Standard Chinchilla
next/navigation is the correct one to use here
OcicatOP
i just deleted the html but i think thats not the problem
Standard Chinchilla
can you put back the html
thier could be like a short circuit in there that is using the location
OcicatOP
yeah shure wait
its updated now
Standard Chinchilla
I'm guessing this line is the problem:
Willkommen {user ? user.displayName : router.push("/sign-in")},{" "}Answer
OcicatOP
wait i'll delete it and try it again.
bro. your a genius!
Thankss!
Standard Chinchilla
no problem
it's best practice to use the router functions inside of an effect or event handler
@Standard Chinchilla it's best practice to use the router functions inside of an effect or event handler
OcicatOP
i'll keep it in mind!