Next.js Discord

Discord Forum

error <Html> should not be imported outside of pages/_document. after running "yarn build"

Unanswered
Transvaal lion posted this in #help-forum
Open in Discord
Transvaal lionOP
✓ Linting and checking validity of types
✓ Collecting page data
Generating static pages (1/5) [= ]
Error: <Html> should not be imported outside of pages/_document.
Read more: https://nextjs.org/docs/messages/no-document-import-in-page

18 Replies

Somali
Check to see if you’re importing next/document or <html> in any other file besides _document.tsx.
@Somali Check to see if you’re importing next/document or <html> in any other file besides _document.tsx.
Transvaal lionOP
im not importing next/document nowhere in my source
Somali
How about the <html> tag?
Do you have a custom document file at all?
@Somali Do you have a custom document file at all?
Transvaal lionOP
Somali
You sure you haven’t imported that <html> tag anywhere?
Transvaal lionOP
This is still not fixed then
Transvaal lionOP
working on this issue since almost 10 hours now
@Transvaal lion working on this issue since almost 10 hours now
Somali
@Transvaal lion What version of next are you on? And do you have experimental edge rendering enabled?
next@13.4.7 doesn’t appear to have the same issue. I’d try downgrading and see if the issue persists
@Somali Do you have a custom document file at all?
Somali
^ do you have a custom document?
Scottish Fold
I'm using next@14.0.1 and just tried to deploy to vercel today and I'm getting that error. I don't get the error locally on my M2 Mac, only when deploying to Vercel.

I don't have any occurences of importing Html anywhere. It's just in my src/app/layout that I have an html tag wrapping everything.
Scottish Fold
I've noticed it isn't an issue after I switched from bun to npm.
@Scottish Fold I've noticed it isn't an issue after I switched from `bun` to `npm`.
Somali
Odd. Bun was the cause of the issue here?
Scottish Fold
Looks like it :/ because it don’t have issues with it locally. I noticed Vercel was using bun 1.0.6 and I was using bun 1.0.7 locally…