Using pageExtensions + app route build fail `ENOENT: .next/server/app/api/.../route_client-reference-manifest.js`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
To Reproduce
Considering this simple route in src/app/api/test/route.ts:
export async function GET() {
return new Response("Hello, world!");
}
If I want to use the pageExtensions feature in the next.config.ts:
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* config options here */
pageExtensions: ["p.ts", "p.tsx"],
};
export default nextConfig;
Meaning that I rename:
src/app/layout.tsx=>src/app/layout.p.tsxsrc/app/page.tsx=>src/app/page.p.tsxsrc/app/test/route.ts=>src/app/test/route.p.ts
Then the build crashes with the following log:
$ pnpm build
> next-v15@0.1.0 build /Users/mathieu/Code/FantiumAG/next-v15
> next build
▲ Next.js 15.2.1
Creating an optimized production build ...
✓ Compiled successfully
✓ Linting and checking validity of types
Collecting page data .[Error: ENOENT: no such file or directory, open '/Users/mathieu/Code/FantiumAG/next-v15/.next/server/app/api/test/route_client-reference-manifest.js'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/Users/mathieu/Code/FantiumAG/next-v15/.next/server/app/api/test/route_client-reference-manifest.js'
}
> Build error occurred
[Error: Failed to collect page data for /api/test] { type: 'Error' }
See https://github.com/matbour/next15.2.1-page-extensions-error/tree/9bd6f268d4d952fb6ac7b80391a04cf26dd6550c reproduction + associated GitHub workflow run
Current vs. Expected behavior
Expected behavior is that the build passes, like in https://github.com/matbour/next15.2.1-page-extensions-error/commit/a13fb6d0010073e9184624b7c48e2c3abb00235b where I remove the page extensions. You can also see that the build passes in Github Actions.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:24 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6030
Available memory (MB): 18432
Available CPU cores: 12
Binaries:
Node: 22.13.0
npm: 10.9.2
Yarn: N/A
pnpm: 9.13.2
Relevant Packages:
next: 15.2.1 // Latest available version is detected (15.2.1).
eslint-config-next: 15.2.1
react: 19.0.0
react-dom: 19.0.0
typescript: 5.8.2
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Route Handlers
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Clone the linked reproduction at commit 9bd6f268d4d952fb6ac7b80391a04cf26dd6550c and inspect src/app/api/test/route.p.ts alongside next.config.ts. Run pnpm build with pageExtensions set to p.ts and p.tsx, then compare the generated .next/server/app/api/test files with the failing lookup for route_client-reference-manifest.js. Done means the same renamed route builds successfully, as in commit a13fb6d0010073e9184624b7c48e2c3abb00235b.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, typescript
- Domain
- api, build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100