NextJS 14: <Html> should not be imported outside of pages/_document. Vercel Deployment Fails
Link to the code that reproduces this issue
https://github.com/barrymichaeldoyle/bmd-web
To Reproduce
- Attempt to deploy this app on Vercel
- See it fail with
<Html> should not be imported outside of pages/_document
Current vs. Expected behavior
Currently I can build this app locally with bun with no issues, but the moment I try to deploy to Vercel it throws that error. The installation steps locally and on Vercel are exactly the same, but on Vercel it fails with <Html> should not be imported outside of pages/_document
I don't even have a pages/_document because I'm using Next 14 with App Router.
Verify canary release
- [X] I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:43:05 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6020
Binaries:
Node: 18.16.0
npm: 9.5.1
Yarn: 1.22.19
pnpm: 8.8.0
Relevant Packages:
next: 14.0.1
eslint-config-next: 14.0.0
react: 18.2.0
react-dom: 18.2.0
typescript: 5.2.2
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Not sure
Additional context
I've tried both with [email protected] and [email protected]
Can confirm the issue goes away when I switched from using bun to npm
bumping the issue as I'm having the same problem, [email protected], using app router and getting same warning for every static page
I have the same issue
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!
I have the same issue
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!
lol @ maintainer bot.
NODE_ENV=production next build solved the problem.
This is such a dumb error. I was getting this locally trying to test the build and couldn't figure out why. Thanks @WooodHead for pointing in the right direction
Why it's dumb? Well, I'm only using the app dir, I am not importing Html anywhere and it's completely unrelated
Any movement on this issue? I am using nextjs 15, app router, and so yeah not importing Html anywhere. What the hell is going on with this issue?
I can't build the original repro as it gives me Collecting page data ..Error: Failed to generate static params for blog posts
It looks like the issue is caused by the envrionment override either in some package manager or mabye on user side. I'll close this for now.
If you're still facing the error please file a new issue with your reproduction. Thanks