I was moving my fullstack app (React + Express) from Heroku. The problem was that React app has to be built for running (also has to install required dependencies), but on git we usually store only raw source code.
A common structure for fullstack projects:
Heroku has the option to run scripts after deployment with a special script in the package.json
file:
"heroku-postbuild": "npm install --prefix client && npm run build --prefix client"
But I didn't find a similar ability on Railway.
So my solution is:
.gitignore
fileI had some problems with this, so I am sharing the easiest solution for others.
By selecting a project on Railway, and going to its settings, you would find a field named Build Command
. There you can add your build commands. For example, in your specific case, this should work:
cd client && npm install && npm run build && cd .. && npm i
If it does not work, look at your project structure and adapt the command. Currently, the field is there:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With