next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Error: app-paths-manifest.json not found in .next/server/app/.../route (works when running npm run build && npm run start, fails in npm run dev)

Open TheodoreRed opened this issue 1 year ago • 7 comments

Link to the code that reproduces this issue

https://github.com/TheodoreRed/reproduce-next-15.1.7-bug

To Reproduce

  1. Clone the repo and install dependencies:

    npm install
    
  2. Start the dev server:

    npm run dev
    
  3. Make a GET request to:

    http://localhost:3000/api/dummy/982h89f9082h3/something
    
  4. Observe the error in the terminal:

    ⨯ [Error: ENOENT: no such file or directory, open '/path/to/project/.next/server/app/api/dummy/[signal_id]/something/[__metadata_id__]/route/app-paths-manifest.json'] {
      errno: -2,
      code: 'ENOENT',
      syscall: 'open',
      path: '/path/to/project/.next/server/app/api/dummy/[signal_id]/something/[__metadata_id__]/route/app-paths-manifest.json'
    }
    
  5. Attempt removing the .next folder or clearing caches (e.g., rm -rf .next), then rerun npm run dev – the error persists.

  6. Build and run in production mode (npm run build && npm run start) – the error does not occur.


Current vs. Expected behavior

Current Behavior:

  • The development server throws the above ENOENT error whenever a request is made to /api/dummy/[signal_id]/something.
  • Clearing the .next folder does not fix the issue.
  • Production mode builds and runs without error.

Expected Behavior:

  • The development server should not crash or fail to find app-paths-manifest.json when making requests to the API route.
  • The dev environment should run as smoothly as production does.

Provide environment information

npx --no-install next info
/bin/sh: yarn: command not found

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:04 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8122
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 22.12.0
  npm: 10.9.0
  Yarn: N/A
  pnpm: 9.15.0
Relevant Packages:
  next: 15.1.7 // There is a newer version (15.2.0) available, upgrade recommended! 
  eslint-config-next: 15.1.7
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.5.4
Next.js Config:
  output: N/A
 ⚠ There is a newer version (15.2.0) available, upgrade recommended! 
   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
theo.redlon@Theos-MacBook-Air exlog-sparrowhawk-webapp %

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

Not sure

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

next dev (local)

Additional context

No response

TheodoreRed avatar Mar 03 '25 20:03 TheodoreRed

I attempted updating Next.js to canary with the following steps:

npm install next@canary
changed 3 packages, and audited 432 packages in 7s
149 packages are looking for funding
  run `npm fund` for details
found 0 vulnerabilities

Then, running the dev server again (npm run dev) produced these errors:

> [email protected] dev
> next dev --turbopack

   ▲ Next.js 15.2.1-canary.5 (Turbopack)
   - Local:        http://localhost:3000
   - Network:      http://192.168.2.216:3000
   - Environments: .env.local

 ✓ Starting...
 ✓ Ready in 2.9s
 ○ Compiling /api/dummy/[signal_id]/something ...
 ✓ Compiled /api/dummy/[signal_id]/something in 1430ms
 ⨯ ./node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html
Unknown module type
This module doesn't have an associated type. Use a known file extension, or register a loader for it.

Read more: https://nextjs.org/docs/app/api-reference/next-config-js/turbo#webpack-loaders

./node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:76:15
Module not found: Can't resolve 'aws-sdk'
  74 |
  75 |   // if not mocking then setup real s3.
> 76 |   const AWS = require('aws-sdk');
     |               ^^^^^^^^^^^^^^^^^^
  ...
...
GET /api/dummy/982h89f9082h3/something 500 in 2406ms

After upgrading to Next.js 15.2.0 (canary), I’m now seeing these module resolution errors (e.g., aws-sdk, mock-aws-s3, nock) when using npm run dev with Turbopack.


TheodoreRed avatar Mar 03 '25 20:03 TheodoreRed

The same for me

Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!

romakov avatar Apr 03 '25 19:04 romakov

Ideally this wouldn't be necessary, but add pulsar-client to the serverExternalPackages: ['pulsar-client'] in next.config.js fixes those build errors.

This is the file that causes these problems by pulling in @mapbox/node-pre-gyp: https://github.com/apache/pulsar-client-node/blob/b79ead00441779a348e921f1aa638f1e2dce35c9/src/pulsar-binding.js#L19-L26 and then https://github.com/mapbox/node-pre-gyp/blob/a541932680034f5de9e7365ef8d9a0d7a11cc1a9/lib/node-pre-gyp.js#L286-L288

mischnic avatar Apr 10 '25 07:04 mischnic

@mischnic thanks for your findings. May I ask how do you found the root cause? I'm having the same issue in my project but I don't have pulsar-client as a depdendency

Fredy avatar Apr 10 '25 14:04 Fredy

That is the workaround/fix for this error:

 ⨯ ./node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html
Unknown module type
This module doesn't have an associated type. Use a known file extension, or register a loader for it.

app-paths-manifest.json being missing points to the build failing for some reason (but not printing out the actual reason). So I don't know why that was the case originally here

mischnic avatar Apr 10 '25 19:04 mischnic

Related: routes-manifest.json and app-paths-manifest.json disappear after cold start on Windows

Experiencing a similar issue on Windows 11 with Next.js 15.4.11 in dev mode.

Reproduction

  1. Delete the .next directory entirely
  2. Start next dev
  3. Request / — compiles successfully, returns 200 OK
  4. Server then compiles /_error (triggered automatically)
  5. Request / again — returns 500, with:
Error: ENOENT: no such file or directory, open '.next/routes-manifest.json'
Error: ENOENT: no such file or directory, open '.next/server/app-paths-manifest.json'

Key observation

  • The first request after cold start succeeds (200)
  • After /_error compiles, routes-manifest.json disappears or becomes inaccessible
  • All subsequent requests return 500 indefinitely
  • The server never self-recovers — requires full restart
  • If .next cache exists from a prior session, everything works fine

Server logs

✓ Compiled / in 14.6s (6512 modules)
GET / 200 in 16891ms
✓ Compiled /_error in 3.5s (7143 modules)
⨯ [Error: ENOENT: no such file or directory, open '.next/routes-manifest.json']
GET / 500 in 6719ms

Environment

  • Next.js: 15.4.11
  • Node.js: 22.x
  • OS: Windows 11 Pro
  • No custom outputFileTracingRoot or other build config overrides

Workaround

Keep the .next cache from a prior session — never delete it before starting the dev server. This avoids the cold-start manifest corruption.

This appears to be a race condition where the /_error compilation invalidates or overwrites the manifest files generated during the initial / compilation.

joerizz23 avatar Feb 19 '26 20:02 joerizz23

Thanks for reporting this. Since Next.js 15.2.0, next dev no longer fails with the misleading app-paths-manifest.json ENOENT error. It now reports the real compile errors from bundling pulsar-client's @mapbox/node-pre-gyp dependency, which go away when you add serverExternalPackages: ['pulsar-client'] as @mischnic explained above (docs). With your reproduction, I got the unhelpful failure on 15.1.7 and 15.2.0-canary.14, the real errors on 15.2.0-canary.15, 16.4.3 and 16.5.0-canary.35, and a 200 response on 16.5.0-canary.35 with that config; the separate Turbopack next build crash for this package (missing field napi_versions) is tracked in #97935.

Closing as completed; if you still see the app-paths-manifest.json error on the latest canary, comment here and we'll reopen it.

github-actions[bot] avatar Nov 27 '26 05:11 github-actions[bot]