Unable to build or deploy a nodejs/ejs app.

Unable to build or deploy a nodejs/ejs app, although it runs ok with desktop localhost. I am new to web dev and Rail.
No description
43 Replies
Brody
Brody6mo ago
do you use yarn or npm locally?
thomas
thomas6mo ago
It is possible that this was related to our last incident. It has been fully resolved now. @BobPar_21
Brody
Brody6mo ago
i dont think so, their install command is npm ci but their build and start commands use yarn, they are also trying to do a yarn install in the build phase
thomas
thomas6mo ago
Sounds correct to me
Brody
Brody6mo ago
yeah theres some stuff to unpack and work through here
BobPar_21
BobPar_216mo ago
NPM
Brody
Brody6mo ago
do you have a yarn lock file in your project?
BobPar_21
BobPar_216mo ago
No yarn lock
Brody
Brody6mo ago
do you have any build or start commands set in the service settings?
BobPar_21
BobPar_216mo ago
Only that supplied by Rail during build.
Brody
Brody6mo ago
railway does not set any build or start commands in the service settings, please go check
BobPar_21
BobPar_216mo ago
in the railway.toml file
Brody
Brody6mo ago
do you have a railway.toml file?
BobPar_21
BobPar_216mo ago
Only the yarn commands, they are greyed out.
Brody
Brody6mo ago
delete the railway.toml file please
BobPar_21
BobPar_216mo ago
Yes , i do have the railway.toml file in the git repository. for some reason, it is duplicated in the repository.
Brody
Brody6mo ago
delete it please
BobPar_21
BobPar_216mo ago
both?
Brody
Brody6mo ago
yes
BobPar_21
BobPar_216mo ago
done
Brody
Brody6mo ago
did the new build fail?
BobPar_21
BobPar_216mo ago
looks like the build is ok still does not deploy
BobPar_21
BobPar_216mo ago
I have not added any shared variables and no action has been taken with the mongo service.
Brody
Brody6mo ago
then your app is likely crashing because it cant connect to mongo
BobPar_21
BobPar_216mo ago
Sorry I had some problems with the log download. I can add shared variables, based on my best guess. at least you got it to build. I see it could not connect to the mongo service in the logs
Brody
Brody6mo ago
makes sense
BobPar_21
BobPar_216mo ago
Ok, i was able to get it to connect to mongo, based on the deploy log. Still not deploying.
Brody
Brody6mo ago
deploy logs please
BobPar_21
BobPar_216mo ago
Here is the log entries npm WARN config production Use --omit=dev instead.
secrets---starting-code@1.0.0 start
node index.js
Warning: connect.session() MemoryStore is not designed for a production environment, as it will leak memory, and will not scale past a single process. Server on Port 3000... Connected to MongoDB... Still cant get that link to work sorry.
BobPar_21
BobPar_216mo ago
okay, I made the recommended change for host and port in my index.js file. Still cannot get deployment. Here is the log: npm WARN config production Use --omit=dev instead.
secrets---starting-code@1.0.0 start
node index.js
Warning: connect.session() MemoryStore is not designed for a production environment, as it will leak memory, and will not scale past a single process. Connected to MongoDB... Any other ideas for troubleshooting?
Brody
Brody6mo ago
show me the code changes you have made please
BobPar_21
BobPar_216mo ago
// Use PORT provided in environment or default to 3000 const port = process.env.PORT || 3000; // Listen on port and 0.0.0.0 app.listen(port, "0.0.0.0", function () { // ... });
Brody
Brody6mo ago
that's just copying from the docs page, is that what you are using in code now?
BobPar_21
BobPar_216mo ago
yes
Brody
Brody6mo ago
what do you get when you visit the url
BobPar_21
BobPar_216mo ago
I am simply inserting localhost:3000 in the address bar in Chrome and it gets rejected. Is this a browser issue?
Brody
Brody6mo ago
what does localhost have to do with railway? you are running your app on railway, you need to use the railway domain
BobPar_21
BobPar_216mo ago
I am simply clicking on the link provided for the deployment which should work. Can you elaborate?
Brody
Brody6mo ago
does your service have a railway provided domain? if it doesn't, go to the service settings and generate one
BobPar_21
BobPar_216mo ago
let me see.... IT WORKED!!!! THANKS. You have no idea how much time I have wasted working this problem on my on.
Brody
Brody6mo ago
no problem!