R
Railway•10mo 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•10mo ago
Project ID: ef969482-2fdd-4621-9512-7322fbaf5699
Brody
Brody•10mo 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
FalkinerOP•10mo 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•10mo ago
its far from best practice, the build should be ran during build, please remove it
Falkiner
FalkinerOP•10mo 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•10mo ago
definitely dont want to run a build in the start command regardless of the core issue here
Falkiner
FalkinerOP•10mo ago
there's any way I can check the file structure inside Railway?
Brody
Brody•10mo ago
there is no native filebrowser or ssh
Falkiner
FalkinerOP•10mo 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
FalkinerOP•10mo ago
if I try to build on my local machine
No description
Falkiner
FalkinerOP•10mo ago
npm run build and npm run start works as intended
Brody
Brody•10mo ago
well is npm run build being ran during build on railway?
Falkiner
FalkinerOP•10mo 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•10mo ago
using nixpacks right?
Falkiner
FalkinerOP•10mo ago
yes!
Falkiner
FalkinerOP•10mo ago
one sec
Brody
Brody•10mo ago
and if you delete your local dist folder, and run a build, where does that dist folder get put?
Falkiner
FalkinerOP•10mo 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•10mo ago
nope, please get the project working properly before you try running it on railway again
Falkiner
FalkinerOP•10mo ago
ok, thanks ok, just managed to get it working now since Prisma had an .ts file on it's folder
Brody
Brody•10mo ago
works on railway too?
Falkiner
FalkinerOP•10mo 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