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.
43 Replies
do you use yarn or npm locally?
It is possible that this was related to our last incident. It has been fully resolved now. @BobPar_21
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 phaseSounds correct to me
yeah theres some stuff to unpack and work through here
NPM
do you have a yarn lock file in your project?
No yarn lock
do you have any build or start commands set in the service settings?
Only that supplied by Rail during build.
railway does not set any build or start commands in the service settings, please go check
in the railway.toml file
do you have a railway.toml file?
Only the yarn commands, they are greyed out.
delete the railway.toml file please
Yes , i do have the railway.toml file
in the git repository. for some reason, it is duplicated in the repository.
delete it please
both?
yes
done
did the new build fail?
looks like the build is ok
still does not deploy
build logs please https://bookmarklets.up.railway.app/log-downloader/
I have not added any shared variables and no action has been taken with the mongo service.
then your app is likely crashing because it cant connect to mongo
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
makes sense
Ok, i was able to get it to connect to mongo, based on the deploy log. Still not deploying.
deploy logs please
Here is the log entries npm WARN config production Use
--omit=dev
instead.
[email protected] start
node index.jsWarning: 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.
please read this page https://docs.railway.app/guides/fixing-common-errors
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.
[email protected] start
node index.jsWarning: 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?
show me the code changes you have made please
// 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 () {
// ...
});that's just copying from the docs page, is that what you are using in code now?
yes
what do you get when you visit the url
I am simply inserting localhost:3000 in the address bar in Chrome and it gets rejected. Is this a browser issue?
what does localhost have to do with railway?
you are running your app on railway, you need to use the railway domain
I am simply clicking on the link provided for the deployment which should work. Can you elaborate?
does your service have a railway provided domain?
if it doesn't, go to the service settings and generate one
let me see....
IT WORKED!!!! THANKS. You have no idea how much time I have wasted working this problem on my on.
no problem!