Pinpoint cause of Next.js pre-render error?
Unanswered
English Lop posted this in #help-forum
English LopOP
I built my code a few times before without issues. Then I made some changes recently, and I am now getting a pre-render error when I build. I don't know how to pinpoint the point of failure because the error in the terminal doesn't reference a specific file. FYI I am using a third party SDK and in the cases that it applies, i'm using dynamic import with next/dynamic. Is there a way to narrow down the possibilties for point of failure? Here's the error:
Generating static pages (4/27) [= ]ReferenceError: document is not defined
at /home/mrz/repos/demo-app/.next/server/chunks/134.js:22:882465
at /home/mrz/repos/demo-app/.next/server/chunks/134.js:22:883591
at 84244 (/home/mrza/repos/demo-app/.next/server/chunks/134.js:204:18323)
at t (/home/mrza/repos/demo-app/.next/server/webpack-runtime.js:1:143)
at 25761 (/home/mrza/repos/demo-app/.next/server/chunks/236.js:1:30328)
at Object.t [as require] (/home/mrza/repos/demo-app/.next/server/webpack-runtime.js:1:143)
at require (/home/mrza/repos/demo-app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:18678)
at i (/home/mrza/repos/demo-app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:88294)
at /home/mrza/repos/demo-app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:98817
at /home/mrza/repos/demo-app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:98904 {
digest: '1395371431'
}
Error occurred prerendering page "/analytics/editableDashboard". Read more: https://nextjs.org/docs/messages/prerender-error20 Replies
English LopOP
@goose thanks, I am not sure if it's that document specifically b/c the error is much longer, basically saying "document is not defined" for many other files too.
@Daggertooth pike conger
@English Lop @goose thanks, I am not sure if it's that document specifically b/c the error is much longer, basically saying "document is not defined" for many other files too.
Daggertooth pike conger
what packaes are you using
in analytics editable dashboard
English LopOP
@Daggertooth pike conger I found a clue
Daggertooth pike conger
?
English LopOP
When i run my local dev server, i see this error:
⨯ ReferenceError: document is not defined
at __webpack_require__ (/home/mrzamin/repos/ai-demo-app/.next/server/webpack-runtime.js:33:43)
at eval (layout.tsx:7:87)
at (ssr)/./src/app/(site)/layout.tsx (/home/mrza/repos/demo-app/.next/server/app/(site)/page.js:149:1)
at Object.__webpack_require__ [as require] (/home/mrza/repos/demo-app/.next/server/webpack-runtime.js:33:43)
digest: "3833627994"Pointing to the layout file. But i don't know what's wrong with it
"use client"
import { MetabaseProvider } from "@metabase/embedding-sdk-react";
import ToastContext from "../contexts/ToastContext";
import React from "react";
import { getMetabaseTheme } from "../components/Metabase/MetabaseTheme";
import { useTheme } from "../contexts/ThemeContext";
import { authConfig } from "../components/Metabase/MetabaseConfig";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
const { colorMode } = useTheme()
const theme = getMetabaseTheme(colorMode);
return (
<MetabaseProvider authConfig={authConfig} theme={theme}>
<ToastContext />
{children}
</MetabaseProvider>
);
}Daggertooth pike conger
well
wat bout metabaseprovider
English LopOP
hmm i've got a mix here of async operations and client side hooks
Daggertooth pike conger
u see the word document?
English LopOP
@Daggertooth pike conger
No
Do you mean, do I see the HTML/body elements declared?