Getting Error: <Html> should not be imported outside of pages/_document ath App Directory
Answered
Serengeti posted this in #help-forum
SerengetiOP
2024-06-27T08:03:36.481Z [WARNING]: Error: <Html> should not be imported outside of pages/_document.
Read more: https://nextjs.org/docs/messages/no-document-import-in-pageHow come i get this error when im using app dirrectory?
Answered by Serengeti
Solution: fix all of the warnings in the build
Issue & Solution Reference: https://nextjs-forum.com/post/1255817255552548964
Issue & Solution Reference: https://nextjs-forum.com/post/1255817255552548964
16 Replies
SerengetiOP
layout:
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import { Toaster } from "react-hot-toast";
import { SessionProvider } from "next-auth/react";
import { Providers } from "./providers";
import "./globals.css";
const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = {
title: process.env.NEXT_PUBLIC_SITE_NAME || "Create Next App",
description: "Generated by create next app",
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body>
<Providers>
<SessionProvider>
{children}
</SessionProvider>
<Toaster />
</Providers>
</body>
</html>
);
}@Serengeti
2024-06-27T08:03:36.481Z [WARNING]: Error: <Html> should not be imported outside of pages/_document.
Read more: https://nextjs.org/docs/messages/no-document-import-in-page
How come i get this error when im using app dirrectory?
are you using
<Html> or <html> in the root layout? (they are different)oh nvm
SerengetiOP
html
your code looks good...
try: stop the dev server, then delete the
.next folder, then run the dev server againSerengetiOP
im getting this error at aws amplify, ill try at vercel if ill get the same issue
@joulev try: stop the dev server, then delete the `.next` folder, then run the dev server again
SerengetiOP
.next is not included in repo
it will regenerate new if ever i run again
@Serengeti im getting this error at aws amplify, ill try at vercel if ill get the same issue
you are not using the dev server? that's even more weird
yeah try vercel
SerengetiOP
ill try to re-deploy while preparing vercel
SerengetiOP
i forgot i am using prisma, so it will have issues with vercel. so ill try netlify as my last testing resort
netlify is weird too
SerengetiOP
ill get back, ill try to fix all of the warning first.
SerengetiOP
Solution: fix all of the warnings in the build
Issue & Solution Reference: https://nextjs-forum.com/post/1255817255552548964
Issue & Solution Reference: https://nextjs-forum.com/post/1255817255552548964
Answer