nx icon indicating copy to clipboard operation
nx copied to clipboard

Can't serve Next.js apps in production after "successfull" build

Open natashasq opened this issue 2 years ago • 0 comments

Current Behavior

After migration to NX v16.3.2 I can't serve Next.js apps in production.

Although the production build passes successfully by NX report, many files are missing in dist/apps/[app_name] folder. In my case name of the app is "links', but it is the same for all other apps.

I know that error is coming because of the files that are missing from here, but I don't know how to fix that. dist folder

I'll appreciate every help :)

Expected Behavior

To find all necessary files in dist/apps/[app_name] and to be able to run serve in production mode.

GitHub Repo

No response

Steps to Reproduce

Nx Report

> nx run links:serve:production

- ready started server on 0.0.0.0:4202, url: http://localhost:4202
Error: Could not find a production build in the 'C:\Users\ExamRoom AI\Documents\front-blueprint\frontend-v1\blockport\dist\apps\links\.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 NextNodeServer.getBuildId (C:\Users\ExamRoom AI\Documents\front-blueprint\frontend-v1\blockport\node_modules\next\dist\server\next-server.js:342:23)
    at new Server (C:\Users\ExamRoom AI\Documents\front-blueprint\frontend-v1\blockport\node_modules\next\dist\server\base-server.js:151:29)    
    at new NextNodeServer (C:\Users\ExamRoom AI\Documents\front-blueprint\frontend-v1\blockport\node_modules\next\dist\server\next-server.js:172:9)
    at NextServer.createServer (C:\Users\ExamRoom AI\Documents\front-blueprint\frontend-v1\blockport\node_modules\next\dist\server\next.js:171:24)
    at async C:\Users\ExamRoom AI\Documents\front-blueprint\frontend-v1\blockport\node_modules\next\dist\server\next.js:196:31
    at async NextServer.prepare (C:\Users\ExamRoom AI\Documents\front-blueprint\frontend-v1\blockport\node_modules\next\dist\server\next.js:153:24)
    at async Server.<anonymous> (C:\Users\ExamRoom AI\Documents\front-blueprint\frontend-v1\blockport\node_modules\next\dist\server\lib\render-server.js:121:17) {
  type: 'Error'
}
 >  NX   Next.js app exited with code 1
   Pass --verbose to see the stacktrace.

 —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— 

 >  NX   Running target serve for project links failed

   Failed tasks:

   - links:serve:production

   Hint: run the command with --verbose for more details.

Failure Logs

No response

Operating System

  • [ ] macOS
  • [ ] Linux
  • [X] Windows
  • [ ] Other (Please specify)

Additional Information

No response

natashasq avatar Jun 16 '23 09:06 natashasq