#Error in production build Next.js 14

1 messages · Page 1 of 1 (latest)

potent mason
#

I'm trying to build my next.js (version 14.0.1) site, but it's showing an error that says:

Error: <Html> should no be imported outside of pages/_document.

However, it hasn't sense, because with app router the pages/_document doesn't exists intead layout exists and it's not importing <Html> component (from Next) but uses de native <html> tag.

quartz beaconBOT
#

Hi @potent mason. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in the extracts, it seems like you're encountering a common issue with Next.js where the <Html> component is being imported outside of the pages/_document file. This is not allowed in Next.js and can cause the error you're seeing.

The <Html> component is a built-in component in Next.js and should only be used in a custom Document. The Document is used to augment your application's <html> and <body> tags, and this customization is only allowed within the _document.js or _document.tsx file in the pages directory.

If you're not importing <Html> in your files, it's possible that a third-party library or package you're using might be doing so. You can try to identify this by checking the error stack trace, which should point you to the file where <Html> is being wrongly imported.

For more information, you can refer to the Next.js documentation on custom Document: **https://nextjs.org/docs/messages/no-document-import-in-page** (https://nextjs.org/docs/messages/no-document-import-in-page)

If you're using NODE_ENV=development in your environment variables, some users have reported that removing this can resolve the issue. However, this seems to be a workaround and not a definitive solution.

Please note that these suggestions are based on the information available in the extracts and might not fully resolve your issue. If the problem persists, I recommend creating an issue in the Next.js GitHub repository or seeking help from the Next.js community.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@potent mason kapa.ai is still learning and improving, please let us know how it did by reacting below

potent mason
#

😮 thats it, the problem is to have the NODE_ENV's value as "development".

rich iris
blissful bear
#

No worries.
I will help you.

#

Please DM.