R
Railway•9mo ago
Falkiner

Node Project not starting on the right path

When trying to start my Node Project, I got the error: "Error: Cannot find module '/app/dist/server.js'" But my start command is: "npm run build && npx prisma migrate deploy && node ./dist/server.js" I don't know where Railways is pulling that /app/ folder
23 Replies
Percy
Percy•9mo ago
Project ID: ef969482-2fdd-4621-9512-7322fbaf5699
Brody
Brody•9mo ago
project files are placed inside an /app folder at the root of the container.
But my start command is: "npm run build && npx prisma migrate deploy && node ./dist/server.js"
why do you have a build command in your start command?
Falkiner
Falkiner•9mo ago
I used to do that before using Railway, but I do have other project that uses the same command and works without issues
Brody
Brody•9mo ago
its far from best practice, the build should be ran during build, please remove it
Falkiner
Falkiner•9mo ago
sure, just a sec I discovered something, now when I build typescript is maintaining the src folder inside dist this was not happening before maybe this is the issue hahaha will do some testing
Brody
Brody•9mo ago
definitely dont want to run a build in the start command regardless of the core issue here
Falkiner
Falkiner•9mo ago
there's any way I can check the file structure inside Railway?
Brody
Brody•9mo ago
there is no native filebrowser or ssh
Falkiner
Falkiner•9mo ago
😦 well still getting the same issue, even after removing the build command from the start Error: Cannot find module '/app/dist/server.js'
Falkiner
Falkiner•9mo ago
if I try to build on my local machine
No description
Falkiner
Falkiner•9mo ago
npm run build and npm run start works as intended
Brody
Brody•9mo ago
well is npm run build being ran during build on railway?
Falkiner
Falkiner•9mo ago
#12 0.647 npm

WARN config production Use `--omit=dev` instead.

#12 0.710

#12 0.710 > [email protected] build

#12 0.710 > tsc

#12 0.710

#12 DONE 3.3s
#12 0.647 npm

WARN config production Use `--omit=dev` instead.

#12 0.710

#12 0.710 > [email protected] build

#12 0.710 > tsc

#12 0.710

#12 DONE 3.3s
looks like yes
Brody
Brody•9mo ago
using nixpacks right?
Falkiner
Falkiner•9mo ago
yes!
Falkiner
Falkiner•9mo ago
one sec
Brody
Brody•9mo ago
and if you delete your local dist folder, and run a build, where does that dist folder get put?
Falkiner
Falkiner•9mo ago
oh, it's creating the server.js inside the src folder again wtf do you have any ideia why this is happening?
Brody
Brody•9mo ago
nope, please get the project working properly before you try running it on railway again
Falkiner
Falkiner•9mo ago
ok, thanks ok, just managed to get it working now since Prisma had an .ts file on it's folder
Brody
Brody•9mo ago
works on railway too?
Falkiner
Falkiner•9mo ago
well I just got the HTTP Server Running on deploy log will test but just in case anyone is using prisma, remember to exclude Prisma folder on your tsconfig
Want results from more Discord servers?
Add your server