Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find a production build in the '.next' directory on Node.js 23 #1021

Open
IMXNOOBX opened this issue Nov 1, 2024 · 12 comments
Open
Labels
bug Something isn't working upstream

Comments

@IMXNOOBX
Copy link

IMXNOOBX commented Nov 1, 2024

To Reproduce

  1. Create a new app npm create fumadocs-app
    image

  2. Move to the directory cd test-app
    image

  3. Execute build command npm run build
    image

  4. Execute start command npm run start
    image

$ npm run start

> test-app@0.0.0 start
> next start

    Next.js 15.0.2
   - Local:        http://localhost:3000

  Starting...
Error: Could not find a production build in the '.next' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id
    at setupFsCheck (D:\asdsadsa\GitHub\poc\test-app\node_modules\next\dist\server\lib\router-utils\filesystem.js:149:19)
    at async initialize (D:\asdsadsa\GitHub\poc\test-app\node_modules\next\dist\server\lib\router-server.js:65:23)
    at async Server.<anonymous> (D:\asdsadsa\GitHub\poc\test-app\node_modules\next\dist\server\lib\start-server.js:266:36)

Current vs. Expected behavior

Following the previous steps it should start the project and host it on port :3000, but it fails stating that next is unable to find the build directory. You dont encounter this issue when running in development mode.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 16252
  Available CPU cores: 16
Binaries:
  Node: 23.0.0
  npm: N/A
  Yarn: N/A
  pnpm: 9.11.0
Relevant Packages:
  next: 15.0.2 // Latest available version is detected (15.0.2).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.6.3
Next.js Config:
  output: N/A

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

Core, CLI (create-fumadocs-app)

Additional context

This issue has been encountered in these OS: Windows 11 23H2 / 10, Linux (Ubuntu 22.04.4 LTS), it happened when migrating from the older "fumadocs-core": "13.4.10",, "next": "^14.2.8", version to the latest one.

@IMXNOOBX IMXNOOBX added the bug Something isn't working label Nov 1, 2024
@IMXNOOBX IMXNOOBX changed the title Could not find a production build in the '.next' directory. when starting Could not find a production build in the '.next' directory. when starting in production Nov 1, 2024
@fuma-nama
Copy link
Owner

Cannot reproduce the error on code sandbox, please provide a minimal reproduction to your issue

@fuma-nama fuma-nama added the question Further information is requested label Nov 2, 2024
@kWAYTV

This comment has been minimized.

@fuma-nama
Copy link
Owner

Please submit a reproduction if you have similar problems

@kWAYTV
Copy link

kWAYTV commented Nov 2, 2024

Please submit a reproduction if you have similar problems

My steps to reproduce are the exact same ones he sent in his submit

@fuma-nama
Copy link
Owner

You need to produce the problem in a repo or code sandbox

@IMXNOOBX
Copy link
Author

IMXNOOBX commented Nov 2, 2024

You need to produce the problem in a repo or code sandbox

I dont know of any code sandbox that i can share with you, so i have created a repo https://github.com/IMXNOOBX/fumadocs-issue-1021

@fuma-nama
Copy link
Owner

Have you tried on a linux machine? (CodeSandbox whenever possible, click the "Open Demo" button on Fumadocs will open a codesandbox).

It works for me (ignore the port already in use one, it's because of other running dev servers)
image

@IMXNOOBX
Copy link
Author

IMXNOOBX commented Nov 2, 2024

Cant reproduce either in the codesandbox, but on a linux server you get the same issue, im sorry i cannot be of more help, but i suggest you try on any other machine you dont use for dev and try it, ive tried in 3 diferent windows machines and in a ubuntu server 22

redacted@redacted:~/github/fumadocs-issue-1021$ node -v
v23.0.0
redacted@redacted:~/github$ git clone https://github.com/IMXNOOBX/fumadocs-issue-1021
Cloning into 'fumadocs-issue-1021'...
remote: Enumerating objects: 31, done.
remote: Counting objects: 100% (31/31), done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 31 (delta 0), reused 31 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (31/31), 53.98 KiB | 26.99 MiB/s, done.
redacted@redacted:~/github$ cd fumadocs-issue-1021/
redacted@redacted:~/github/fumadocs-issue-1021$ npm i
(node:3256662) ExperimentalWarning: Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

> [email protected] postinstall
> fumadocs-mdx

[MDX] types generated

added 390 packages, and audited 391 packages in 9s

160 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
redacted@redacted:~/github/fumadocs-issue-1021$ npm run build

> [email protected] build
> next build

   ▲ Next.js 15.0.2
   - Experiments (use with caution):
     · turbo

   Creating an optimized production build ...
[MDX] initialized map file
(node:3256858) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Unable to snapshot resolve dependencies
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Unable to snapshot resolve dependencies
redacted@redacted:~/github/fumadocs-issue-1021$ npm run start

> [email protected] start
> next start

   ▲ Next.js 15.0.2
   - Local:        http://localhost:3000

 ✓ Starting...
Error: Could not find a production build in the '.next' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id
    at setupFsCheck (/home/redacted/github/fumadocs-issue-1021/node_modules/next/dist/server/lib/router-utils/filesystem.js:149:19)
    at async initialize (/home/redacted/github/fumadocs-issue-1021/node_modules/next/dist/server/lib/router-server.js:65:23)
    at async Server.<anonymous> (/home/redacted/github/fumadocs-issue-1021/node_modules/next/dist/server/lib/start-server.js:266:36)
redacted@redacted:~/github/fumadocs-issue-1021$ node -v
v23.0.0

@fuma-nama
Copy link
Owner

could you degrade node.js to v22 and use pnpm, and see if the problem exists?

@IMXNOOBX
Copy link
Author

IMXNOOBX commented Nov 2, 2024

Seems to work with node v22, no pnpm used in this test

redacted@redacted:~/github/fumadocs-issue-1021$ nvm install v22
Downloading and installing node v22.11.0...
Downloading https://nodejs.org/dist/v22.11.0/node-v22.11.0-linux-arm64.tar.xz...
################################################################################################################################################################################################ 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v22.11.0 (npm v10.9.0)
redacted@redacted:~/github/fumadocs-issue-1021$ node -v
v22.11.0
redacted@redacted:~/github/fumadocs-issue-1021$ npm ci

> [email protected] postinstall
> fumadocs-mdx

[MDX] types generated

added 390 packages, and audited 391 packages in 9s

160 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
redacted@redacted:~/github/fumadocs-issue-1021$ rm .next -R
redacted@redacted:~/github/fumadocs-issue-1021$ npm run build

> [email protected] build
> next build

   ▲ Next.js 15.0.2
   - Experiments (use with caution):
     · turbo

   Creating an optimized production build ...
[MDX] initialized map file
(node:3262628) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
 ✓ Compiled successfully
 ✓ Linting and checking validity of types    
 ✓ Collecting page data    
 ✓ Generating static pages (7/7)
 ✓ Collecting build traces    
 ✓ Finalizing page optimization    

Route (app)                              Size     First Load JS
┌ ○ /                                    171 B           109 kB
├ ○ /_not-found                          897 B           101 kB
├ ƒ /api/search                          137 B           100 kB
└ ● /docs/[[...slug]]                    11.3 kB         158 kB
    ├ /docs
    └ /docs/test
+ First Load JS shared by all            99.9 kB
  ├ chunks/215-429da4f3e8265a89.js       45.2 kB
  ├ chunks/4bd1b696-89a6990571457db2.js  52.6 kB
  └ other shared chunks (total)          2.07 kB


○  (Static)   prerendered as static content
●  (SSG)      prerendered as static HTML (uses generateStaticParams)
ƒ  (Dynamic)  server-rendered on demand

redacted@redacted:~/github/fumadocs-issue-1021$ npm run start

> [email protected] start
> next start

   ▲ Next.js 15.0.2
   - Local:        http://localhost:3000

 ✓ Starting...
 ✓ Ready in 499ms

@fuma-nama
Copy link
Owner

My thought is there's some compatibility issues with Next.js and Node.js 23. Fumadocs is only a library on top of Next.js so we cannot fix this unless the upstream problem get fixed. For now, I recommend to use Node.js 22 as a solution.

@fuma-nama fuma-nama added upstream and removed question Further information is requested labels Nov 2, 2024
@fuma-nama fuma-nama changed the title Could not find a production build in the '.next' directory. when starting in production Could not find a production build in the '.next' directory on Node.js 23 Nov 2, 2024
@IMXNOOBX
Copy link
Author

IMXNOOBX commented Nov 2, 2024

Alright, thanks for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

No branches or pull requests

3 participants