next.js icon indicating copy to clipboard operation
next.js copied to clipboard

NextJS 14: <Html> should not be imported outside of pages/_document. Vercel Deployment Fails

Open barrymichaeldoyle opened this issue 2 years ago • 4 comments

Link to the code that reproduces this issue

https://github.com/barrymichaeldoyle/bmd-web

To Reproduce

  1. Attempt to deploy this app on Vercel
  2. 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]

barrymichaeldoyle avatar Nov 03 '23 08:11 barrymichaeldoyle

Can confirm the issue goes away when I switched from using bun to npm

barrymichaeldoyle avatar Nov 03 '23 13:11 barrymichaeldoyle

bumping the issue as I'm having the same problem, [email protected], using app router and getting same warning for every static page

Gregorein avatar Nov 29 '23 21:11 Gregorein

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!

dgabriele avatar Apr 22 '24 22:04 dgabriele

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.

Gregorein avatar Jun 27 '24 10:06 Gregorein

NODE_ENV=production next build solved the problem.

WooodHead avatar Jul 17 '24 03:07 WooodHead

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

cipriancaba avatar Jul 24 '24 12:07 cipriancaba

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?

LukasDeco avatar Nov 04 '24 21:11 LukasDeco

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

huozhi avatar Jan 13 '25 16:01 huozhi