vercel / next.js

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

next package can't be found when using --turbo and deno 2 rc in a monorepo #70600

Open hamlim opened 2 weeks ago

hamlim commented 2 weeks ago

Link to the code that reproduces this issue

https://github.com/hamlim/deno-monorepo

To Reproduce

  1. Clone the repo
  2. Upgrade to deno 2 release candidate: deno upgrade rc (using at least 2.0.0-rc.7)
  3. Run deno install to install dependencies
  4. Run deno task dev --filter=docs (runs the docs Next app in development mode)
  5. Try to visit localhost:3000
  6. See error in terminal

Current vs. Expected behavior

Following the above steps - I'd expect the app to boot correctly, however it instead shows the following error in the terminal:

docs:dev: $ next dev --turbo
docs:dev:   ▲ Next.js 15.0.0-canary.140 (turbo)
docs:dev:   - Local:        http://localhost:3000
docs:dev:
docs:dev:  ✓ Starting...
docs:dev: [Error: Next.js package not found
docs:dev:
docs:dev: Debug info:
docs:dev: - Execution of get_entrypoints_with_issues failed
docs:dev: - Execution of Project::entrypoints failed
docs:dev: - Execution of PagesProject::to_endpoint failed
docs:dev: - Execution of PagesStructureItem::new failed
docs:dev: - Execution of FileSystemPath::join failed
docs:dev: - Execution of get_next_package failed
docs:dev: - Next.js package not found] {
docs:dev:   code: 'GenericFailure'
docs:dev: }

Note:

Removing --turbo on the dev task within apps/docs/package.json makes it work as expected.

My assumption is that turbopack (maybe) is unable to resolve the symlinked next package from the root node_modules (next is installed somewhere else with deno and then symlinked I think)

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: 24.0.0
  Available memory (MB): 24576
  Available CPU cores: 8
Binaries:
  Node: 20.11.1
  npm: 10.8.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.0.0-canary.140 // There is a newer canary version (15.0.0-canary.173) available, please upgrade!
  eslint-config-next: N/A
  react: 19.0.0-rc-7771d3a7-20240827
  react-dom: 19.0.0-rc-7771d3a7-20240827
  typescript: 5.4.5
Next.js Config:
  output: N/A
 ⚠ There is a newer canary version (15.0.0-canary.173) available, please upgrade!
   Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
   Read more - https://nextjs.org/docs/messages/opening-an-issue

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

Module Resolution, Turbopack

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

next dev (local)

Additional context

Will attempt to replicate with the latest canary!

hamlim commented 2 weeks ago

The error is slightly different but still present in the latest canary (15.0.0-canary.173):

docs:dev: $ next dev --turbo
docs:dev:   ▲ Next.js 15.0.0-canary.173 (turbo)
docs:dev:   - Local:        http://localhost:3000
docs:dev:
docs:dev:  ✓ Starting...
docs:dev:  ✓ Ready in 2.8s
docs:dev:  ✓ Compiled / in 4ms
docs:dev:  ✓ Compiled /_error in 0ms
docs:dev:  ⨯ [Error: Next.js package not found
docs:dev:
docs:dev: Debug info:
docs:dev: - Execution of *get_written_endpoint_with_issues failed
docs:dev: - Execution of *PagesProject::to_endpoint failed
docs:dev: - Execution of *PagesStructureItem::new failed
docs:dev: - Execution of *FileSystemPath::join failed
docs:dev: - Execution of get_next_package failed
docs:dev: - Next.js package not found] {
docs:dev:   name: 'TurbopackInternalError'
docs:dev: }
docs:dev: [Error: Failed to write app endpoint /page
docs:dev:
docs:dev: Caused by:
docs:dev: - Next.js package not found
docs:dev:
docs:dev: Debug info:
docs:dev: - Execution of get_written_endpoint_with_issues failed
docs:dev: - Execution of <AppEndpoint as Endpoint>::write_to_disk failed
docs:dev: - Failed to write app endpoint /page
docs:dev: - Execution of AppEndpoint::output failed
docs:dev: - Execution of *get_app_page_entry failed
docs:dev: - Execution of *ModuleAssetContext::new failed
docs:dev: - Execution of get_server_module_options_context failed
docs:dev: - Execution of get_transpiled_packages failed
docs:dev: - Execution of *FileSystem::read failed
docs:dev: - Execution of *FileSystemPath::fs failed
docs:dev: - Execution of *FileSystemPath::join failed
docs:dev: - Execution of get_next_package failed
docs:dev: - Next.js package not found] {
docs:dev:   name: 'TurbopackInternalError'
docs:dev: }
docs:dev:  ⨯ [Error: Next.js package not found
docs:dev:
docs:dev: Debug info:
docs:dev: - Execution of *get_written_endpoint_with_issues failed
docs:dev: - Execution of *PagesProject::to_endpoint failed
docs:dev: - Execution of *PagesStructureItem::new failed
docs:dev: - Execution of *FileSystemPath::join failed
docs:dev: - Execution of get_next_package failed
docs:dev: - Next.js package not found] {
docs:dev:   name: 'TurbopackInternalError'
docs:dev: }
docs:dev: [Error: Next.js package not found
docs:dev:
docs:dev: Debug info:
docs:dev: - Execution of *get_written_endpoint_with_issues failed
docs:dev: - Execution of *PagesProject::to_endpoint failed
docs:dev: - Execution of *PagesStructureItem::new failed
docs:dev: - Execution of *FileSystemPath::join failed
docs:dev: - Execution of get_next_package failed
docs:dev: - Next.js package not found] {
docs:dev:   name: 'TurbopackInternalError'
docs:dev: }
docs:dev:  ✓ Compiled /favicon.ico in 0ms

However also notably there is something shown in the browser where as there was nothing returned before (now it shows the generic Internal Server Error page).