Problem with node
zxq041
HOBBYOP

10 months ago

Hello, since yesterday I have a problem with my projects on railway because it reads them as caddy (only static files) and it doesn't want to read the node backend, please help me.

$15 Bounty

3 Replies

dardameiz
PRO

10 months ago

Hey! Railway's auto-detection switched your Node backend to Caddy, which means it's not finding your Node files properly. Make sure you have a package.json in your repo root - Railway uses that to detect Node projects. If it's there but still detecting as Caddy, you can force Node by adding a nixpacks.toml file with [phases.setup] providers = ["node"] or set a custom start command in your Railway service settings. Did something change in your repo structure yesterday? Check if your package.json got moved or deleted.


alexxdf28-hue
FREE

10 months ago

Option 1: Adjust Root Directory (Recommended)

If your package.json is in a subfolder (e.g., /backend), tell Railway where it is:

  1. In your Railway service dashboard, go to Settings.
  2. Find the Root Directory option.
  3. Enter the name of your folder (e.g., backend).
  4. Redeploy.

Option 2: Force Node.js Start Command

If the file structure is correct, manually force the Node.js build process:

  1. Go to the Settings tab of your service.
  2. In the Deploy section, find the Start Command.
  3. Set it to your Node.js start script (e.g., npm start).

Make sure to

  • Ensure your package.json is in the directory you specified.
  • Make sure the package.json includes a valid "start" script (e.g., "start": "node index.js").

This worked for me so i hope it helps!


dardameiz
PRO

10 months ago

Hey, could you solve it? 🙂


Welcome!

Sign in to your Railway account to join the conversation.

Loading...