vercel / vercel/vercel

@vercel/next: Next 16.2+/Turbopack functions crash at runtime: Cannot find module 'next/dist/server/lib/incremental-cache/tags-manifest.external.js'

Open
#17,554 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
16.3k
Forks
3.8k
Avg merge
2m
Merged PRs (30d)
1

Description

Summary

Deploying a Next.js app on Next 16.2.x or 16.3.x (Turbopack build, the default) produces serverless functions that crash on every request at module load:

Error: Failed to load external module next/dist/compiled/next-server/app-route-turbo.runtime.prod.js:
Error: Cannot find module 'next/dist/server/lib/incremental-cache/tags-manifest.external.js'
Require stack:
- /var/task/node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js
- /var/task/.next/server/chunks/[root-of-the-server]__....js
- /var/task/.next/server/chunks/[turbopack]_runtime.js
- /var/task/.next/server/app/api/<route>/route.js
- /var/task/___next_launcher.cjs

The same happens for pages via app-page-turbo.runtime.prod.js. Result: every node function returns 500; the build itself is green.

Evidence it is the function tracer, not the app
  • next/dist/server/lib/incremental-cache/tags-manifest.external.js exists in the published next package for these versions (verified in local node_modules), and app-route-turbo.runtime.prod.js references it.
  • Local next build completes cleanly; only the deployed functions fail, i.e. the file is dropped when the lambda's node_modules/next/dist is pruned to traced files. The .external.js modules are loaded through the Turbopack runtime's externalRequire, which the tracer evidently cannot see.
  • Controlled comparison on the same commit, same project, four deploys: next 16.1.4 works; 16.2.12 and 16.3.3 both crash with the error above.
  • No user-side workaround exists: outputFileTracingIncludes is not applied under Turbopack builds (build/index.js only calls collect-build-traces when the bundler is not Turbopack), and building with --webpack is not viable for apps with dependencies that rely on Turbopack's tolerance of dangling imports.
Expected

The @vercel/next builder includes the *.external.js runtime modules (at minimum next/dist/server/lib/incremental-cache/** and siblings) that Next >= 16.2 requires at runtime from its compiled turbo runtimes.

Environment
  • next: 16.2.12 / 16.3.3 (broken), 16.1.4 (works)
  • Build: next build (Turbopack default), deployed via git integration and CLI, identical result
  • Runtime: Node 22 serverless functions

Happy to provide additional detail. Filing here since the failure is in function packaging at deploy time; if this belongs in vercel/next.js instead, please redirect.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in build/index.js, where collect-build-traces is only called for non-Turbopack builds, and trace the @vercel/next function packaging path. Reproduce with a Next 16.2.x or 16.3.x Turbopack deployment and inspect which next/dist/server/lib/incremental-cache/*.external.js files are included. Done means the deployed serverless function loads and serves requests without the missing-module error.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, node.js, typescript
Domain
build-system, cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.