Skip to content

Nextjs output directory error#14542

Merged
LukeSheard merged 4 commits intomainfrom
cursor/CIBA-3001-nextjs-output-directory-error-5d0c
Jan 7, 2026
Merged

Nextjs output directory error#14542
LukeSheard merged 4 commits intomainfrom
cursor/CIBA-3001-nextjs-output-directory-error-5d0c

Conversation

@LukeSheard
Copy link
Copy Markdown
Contributor

Add early validation for Next.js output directory and improve error messages to guide users on misconfigurations or empty builds.

The original error message for a missing routes-manifest.json was generic, leading to user confusion when the actual problem was a misconfigured outputDirectory or incorrect Turborepo caching. This PR introduces specific checks for the output directory's existence and content, providing targeted error codes (NEXT_OUTPUT_DIR_MISSING, NEXT_OUTPUT_DIR_EMPTY) and actionable guidance, as well as enhancing the existing NEXT_NO_ROUTES_MANIFEST message.


Linear Issue: CIBA-3001

Open in Cursor Open in Web

Co-authored-by: luke.phillips-sheard <luke.phillips-sheard@vercel.com>
@cursor
Copy link
Copy Markdown

cursor bot commented Jan 5, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 5, 2026

🦋 Changeset detected

Latest commit: f50b698

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@vercel/next Patch
vercel Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 5, 2026

🧪 Test Strategy

Comparing: 1f2a250f50b698 (view diff)

Strategy: Affected packages only

✅ Only testing packages that have been modified or depend on modified packages.

Affected packages - 2 (5%)
  1. @vercel/next
  2. vercel
Unaffected packages - 37 (95%)
  1. @vercel-internals/get-package-json
  2. @vercel/backends
  3. @vercel/build-utils
  4. @vercel/cervel
  5. @vercel/cli-auth
  6. @vercel/client
  7. @vercel/config
  8. @vercel/detect-agent
  9. @vercel/edge
  10. @vercel/elysia
  11. @vercel/error-utils
  12. @vercel/express
  13. @vercel/fastify
  14. @vercel/firewall
  15. @vercel/frameworks
  16. @vercel/fs-detectors
  17. @vercel/functions
  18. @vercel/gatsby-plugin-vercel-builder
  19. @vercel/go
  20. @vercel/h3
  21. @vercel/hono
  22. @vercel/hydrogen
  23. @vercel/introspection
  24. @vercel/nestjs
  25. @vercel/node
  26. @vercel/oidc
  27. @vercel/oidc-aws-credentials-provider
  28. @vercel/python
  29. @vercel/redwood
  30. @vercel/related-projects
  31. @vercel/remix-builder
  32. @vercel/routing-utils
  33. @vercel/ruby
  34. @vercel/rust
  35. @vercel/static-build
  36. @vercel/static-config
  37. examples

Results

  • Unit tests: Only affected packages will run unit tests
  • E2E tests: Only affected packages will run e2e tests
  • Type checks: Only affected packages will run type checks

This comment is automatically generated based on the affected testing strategy

Copy link
Copy Markdown
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

Line 575 uses relative path for readJSON while rest of code uses absolute paths, causing file not found errors

View Details
📝 Patch Details
diff --git a/packages/next/src/index.ts b/packages/next/src/index.ts
index c42219663..06ef0d663 100644
--- a/packages/next/src/index.ts
+++ b/packages/next/src/index.ts
@@ -573,7 +573,7 @@ export const build: BuildV2 = async buildOptions => {
 
   try {
     const data = await readJSON(
-      path.join(outputDirectory, 'output/config.json')
+      path.join(entryPath, outputDirectory, 'output/config.json')
     );
     buildOutputVersion = data.version;
   } catch (_) {

Analysis

The bug exists at line 575 in packages/next/src/index.ts. The code was using a relative path path.join(outputDirectory, 'output/config.json') for the readJSON call. Since readJSON from fs-extra resolves relative paths from the current working directory (process.cwd()), not from entryPath, the file lookup would fail when the working directory differs from entryPath.

This is inconsistent with:

  1. Line 1290: Uses path.join(entryPath, outputDirectory, 'app-path-routes-manifest.json')
  2. Line 591: Explicitly creates absoluteOutputDirectory = path.join(entryPath, outputDirectory)
  3. All subsequent file operations that use the absolute path

The fix changes line 575 to use path.join(entryPath, outputDirectory, 'output/config.json') to create an absolute path, ensuring the file can be found regardless of the current working directory. This makes the code consistent throughout and prevents silent failures in the buildOutputVersion check.

Use entryPath prefix for build output config.json path to be consistent
with the rest of the codebase and ensure the file can be found regardless
of the current working directory.
@LukeSheard LukeSheard marked this pull request as ready for review January 6, 2026 23:04
@LukeSheard LukeSheard requested review from a team, huozhi, ijjk, timneutkens and ztanner as code owners January 6, 2026 23:04
Copy link
Copy Markdown
Contributor

@marc-vercel marc-vercel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - There is a comment from Vade that might be correct.

@LukeSheard LukeSheard merged commit 2eb1b76 into main Jan 7, 2026
166 checks passed
@LukeSheard LukeSheard deleted the cursor/CIBA-3001-nextjs-output-directory-error-5d0c branch January 7, 2026 10:46
tknickman pushed a commit that referenced this pull request Jan 12, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## vercel@50.2.0

### Minor Changes

- Add `vercel env run` command to run commands with environment
variables from the linked Vercel project without writing them to the
filesystem ([#14582](#14582))

- Merge computed rewrites/redirects to routes in Vercel config
([#14518](#14518))

### Patch Changes

- Adding in user configured deploymentId to build output type
([#14497](#14497))

- skip secondary installation for vercel.ts
([#14471](#14471))

- Updated dependencies
\[[`2eb1b7678bece13e442f8404d519bd07891eb500`](2eb1b76),
[`39c95ff6b643a63509571818e67a792df09fd71f`](39c95ff),
[`d63084dac296ccb2077ed742bc2ade0264da851d`](d63084d)]:
    -   @vercel/next@4.15.11
    -   @vercel/build-utils@13.2.5
    -   @vercel/redwood@2.4.6
    -   @vercel/rust@1.0.4
    -   @vercel/static-build@2.8.16
    -   @vercel/backends@0.0.18
    -   @vercel/elysia@0.1.16
    -   @vercel/express@0.1.23
    -   @vercel/fastify@0.1.19
    -   @vercel/go@3.3.0
    -   @vercel/h3@0.1.25
    -   @vercel/hono@0.2.19
    -   @vercel/hydrogen@1.3.3
    -   @vercel/nestjs@0.2.20
    -   @vercel/node@5.5.17
    -   @vercel/python@6.1.6
    -   @vercel/remix-builder@5.5.6
    -   @vercel/ruby@2.2.4

## @vercel/build-utils@13.2.5

### Patch Changes

- Adding in user configured deploymentId to build output type
([#14497](#14497))

- skip secondary installation for vercel.ts
([#14471](#14471))

## @vercel/client@17.2.19

### Patch Changes

- Updated dependencies
\[[`e725853a6c41bed634d1e3e2382596f17a18f342`](e725853),
[`39c95ff6b643a63509571818e67a792df09fd71f`](39c95ff),
[`d63084dac296ccb2077ed742bc2ade0264da851d`](d63084d),
[`567d2d41e685cd949274411ce0e60e61a3dc3942`](567d2d4)]:
    -   @vercel/routing-utils@5.3.2
    -   @vercel/build-utils@13.2.5

## @vercel/elysia@0.1.16

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.5.17

## @vercel/express@0.1.23

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.5.17

## @vercel/fastify@0.1.19

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.5.17

## @vercel/fs-detectors@5.7.12

### Patch Changes

- Updated dependencies
\[[`e725853a6c41bed634d1e3e2382596f17a18f342`](e725853),
[`567d2d41e685cd949274411ce0e60e61a3dc3942`](567d2d4)]:
    -   @vercel/routing-utils@5.3.2
    -   @vercel/frameworks@3.15.4

## @vercel/gatsby-plugin-vercel-builder@2.0.115

### Patch Changes

- Updated dependencies
\[[`39c95ff6b643a63509571818e67a792df09fd71f`](39c95ff),
[`d63084dac296ccb2077ed742bc2ade0264da851d`](d63084d)]:
    -   @vercel/build-utils@13.2.5

## @vercel/h3@0.1.25

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.5.17

## @vercel/hono@0.2.19

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.5.17

## @vercel/nestjs@0.2.20

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/node@5.5.17

## @vercel/next@4.15.11

### Patch Changes

- Add early validation for Next.js output directory and improve error
messages to guide users when the output directory is missing, empty, or
misconfigured. Introduces new error codes `NEXT_OUTPUT_DIR_MISSING` and
`NEXT_OUTPUT_DIR_EMPTY` with actionable guidance for common issues like
Turborepo cache misconfiguration.
([#14542](#14542))

## @vercel/node@5.5.17

### Patch Changes

- Updated dependencies
\[[`39c95ff6b643a63509571818e67a792df09fd71f`](39c95ff),
[`d63084dac296ccb2077ed742bc2ade0264da851d`](d63084d)]:
    -   @vercel/build-utils@13.2.5

## @vercel/routing-utils@5.3.2

### Patch Changes

- Add respectOriginCacheControl to rewritesSchema
([#14506](#14506))

- Add respectOriginCacheControl to routes schema
([#14565](#14565))

## @vercel/static-build@2.8.16

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/gatsby-plugin-vercel-builder@2.0.115

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants