vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.31k stars 27.02k forks source link

Next 15 | Build fails: Can't resolve `next/dist/server/route-modules/app-page/vendored/contexts/html-context` #72231

Open AntoineKM opened 3 weeks ago

AntoineKM commented 3 weeks ago

Link to the code that reproduces this issue

https://github.com/tonightpass/kitchn/pull/749

To Reproduce

  1. Install dependencies with pnpm install
  2. Run pnpm build
  3. Observe the build failure with the above error

Current vs. Expected behavior

The build should complete successfully without any module resolution errors.

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 22.6.0: Wed Jul 31 21:42:48 PDT 2024; root:xnu-8796.141.3.707.4~1/RELEASE_X86_64
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 18.19.0
  npm: 10.2.3
  Yarn: N/A
  pnpm: 9.12.3
Relevant Packages:
  next: 15.0.2 // Latest available version is detected (15.0.2).
  eslint-config-next: 15.0.2
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.6.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Pages Router

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

When trying to build my Next.js project using next build, I'm encountering a module resolution error. The build process fails with the following error:

Failed to compile.

../node_modules/.pnpm/next@15.0.2_@[babel+core@7.26.0_react-dom](mailto:babel+core@7.26.0_react-dom)@[18.3.1_react@18.3.1__react](mailto:18.3.1_react@18.3.1__react)@18.3.1/node_modules/next/dist/pages/_document.js
Module not found: Can't resolve 'next/dist/server/route-modules/app-page/vendored/contexts/html-context'

[https://nextjs.org/docs/messages/module-not-found](https://nextjs.org/docs/messages/module-not-found)

Import trace for requested module:
../node_modules/.pnpm/next@15.0.2_@[babel+core@7.26.0_react-dom](mailto:babel+core@7.26.0_react-dom)@[18.3.1_react@18.3.1__react](mailto:18.3.1_react@18.3.1__react)@18.3.1/node_modules/next/dist/api/document.js
../packages/kitchn/dist/next/index.esm.js

> Build failed because of webpack errors

Any assistance or guidance on resolving this issue would be greatly appreciated. Thank you!

JesseKoldewijn commented 2 weeks ago

Please provide a reproduction and not a link to a PR ;)

AntoineKM commented 1 week ago

I’m reporting this bug as it could potentially affect others if it’s happening in our case. That’s why I’ve shared the PR—to show that no changes were made to the project between the v14 and v15 upgrade, aside from the version bump. Unfortunately, my team will not have the time to investigate further or create a basic reproduction, as the error message isn’t clear enough to pinpoint its source. I hope this still helps in identifying the issue!

JesseKoldewijn commented 1 week ago

Well reproducibility is kind of a requirement for issues as described in the issue template. So I think this issue might get closed soon😅

jorrit commented 4 days ago

This happened with me when I tried to do:

import { Head } from 'next/document';

      <Head>
        <title>Title</title>
      </Head>

I was using the app router, so besides the fact that I should have used Head from next/head, I should have used the metadata api instead.

JesseKoldewijn commented 4 days ago

FYI if the only metadata you want to add in this way is the title, you can also run react 19 and just add a title component at a random location. This gets hoisted up into the head now since this react release🤙