[Error: Could not find a production build in the '.next' directory

yingzhox
PRO

15 days ago

We are unable to deploy nextjs app, its under web folder of a monorepo.

$10 Bounty

2 Replies

Railway
BOT

15 days ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


15 days ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody 15 days ago


15 days ago

  1. Tell Railway to use web/ as your app root
    In your Railway project → SettingsDeploymentRoot Directory, set:

  2. Set your Build & Start commands
    Still under Deployment, update:

    Build Command: npm install && npm run build 
    
    Start Command: npm run start
    
  3. Ensure your web/package.json has the right scripts

    { 
    "scripts": { 
    "build": "next build", 
    "start": "next start" 
      } 
    }

    (Railway will run those from inside web/, so it will find package.json and produce the .next folder.)

  4. Redeploy
    Hit Deploy (or push a dummy commit). You should see

    › Building… › Production build in .next ready › Starting…

    and your app will go live.

That’s it—no extra Dockerfiles or hacks. Railway will look under web/, run npm run build, generate .next, then npm run start.


[Error: Could not find a production build in the '.next' directory - Railway Help Station