Can't deploy my mern app
Hi, just bought railway subscription to deploy my mern app. I used everything I used to deploy my site on render.com and it doesn't work on railway. I'm new into deploying websites so I'll just post 2 screenshots of my problem since I really don't know what am I doing. Thanks!
18 Replies
Please provide your project ID or reply with
N/A
. Thread will automatically be closed if no reply is received within 10 minutes. You can copy your project's id by pressing Ctrl/Cmd + K -> Copy Project ID.1. your frontend build has warnings, warnings are treated as errors, thus your build fails, please resolve the warnings.
2. please do not use nodemon on railway, nodemon in a production environment causes instabilities and uses extra unnecessary resources.
1. Should I resolve every warning? there's about 50 of them?
2. Alright, do I need to uninstall nodemon from my project before deploying it to railway or is there a way to disable it only for deployment?
1. in an ideal world, yes, you would have no warnings, if you don't want to do that though, you can set a service variable
CI
= false
to keep the warnings from causing the build to fail.
2. just don't use nodemon in your start script, nodemon index.js -> node index.js
Alright, thanks man.
in the interest of getting your app running smoothly on railway, how are you serving your frontend app?
I don't understand what "serving" means
fair enough, send me the start scripts section of your frontends package.json please
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
this?
yeah, unfortunately that start script is super not ideal for running your site in a production environment like railway
what do you recommend? I mean my app is only for my portfolio, there won't be any users using that site. I only bought railway, because I want my site to up all the time, on render.com site works but everytime you open it server starts and there's a delay of 1min atleast for content to show up
The only thing that matters is that site is always on
the default start script you see there starts a development server, you absolutely don't want to run a development server on railway, slow, costly, unstable, etc
I will be working on an example repo shortly that demonstrates how to properly run a react/vite app on railway in one of the most efficiently ways possible, think you can wait? lol
Right, I mean I can wait, but I definitely want my site up and running, because I want to start applying for jobs. I will deploy my site and then when you finish doing that example repo, I'll do it correctly
just let me know where will that be posted
I can also google that, will do that now about not running development server
Just one more question
I put this "CI = false" into my frontend -> variables CI is variable name and false is value
rightT?
the Google results will unfortunately not give you a straight forward best approach answer unfortunately
I also wouldn't recommend applying to jobs with a website running in development mode
seems correct to me, show me a screenshot so I can be sure
Right, well at least I know now about not deploying my sites running in development mode, thanks for that
All good man, site is up and running now
thanks for the help, just let me know where i'll be able to see that example you're working on
here on discord or?
ill send you a link to the repo shortly
Alright, thanks man! I really appreciate fast help you saved me a lot of trouble and headaches!
no problem π
here's the newly updated repo
https://github.com/brody192/create-react-app-starter
it uses caddy to serve the react app, please read through the readme.
basically all you should have to do is copy the nixpacks.toml and Caddyfile into your project and push the changes