R
RailwayGhost Order

Installing dependencies for sub directories

My project have this structure
root/
├── client/ (React app)
| ├── .env
| ├── .package.json
| └── src/
├── server/ (Node server)
| ├── .env
| ├── .package.json
| └── src/
└── package.json
root/
├── client/ (React app)
| ├── .env
| ├── .package.json
| └── src/
├── server/ (Node server)
| ├── .env
| ├── .package.json
| └── src/
└── package.json
To run it successfully one have to: 1. install dependencies for both client and server. 2. build the client. 3. start the server In the root's package.json I have this script to install client and server dependencies:
"install": "npm install --prefix client & npm install --prefix server"
"install": "npm install --prefix client & npm install --prefix server"
In local development this works, dependencies both for client first and then server are installed, although the process doesn't exit on its own, I have to manually press Ctrl-C, but then all the next steps work just fine and I can run the application as expected. However when deploy it to railway although it installs the dependencies it fails at the next step (build) because it cannot find both react-script and rimraf, which are necessary to run the build script, which leds me to think that it is not installing the dependencies correctly how can I tell railway to install dependencies for client/ and server/?
P
Percy17d ago
Project ID: 80b7a72a-2271-48a0-8bc9-a5758f24c847
GO
Ghost Order17d ago
80b7a72a-2271-48a0-8bc9-a5758f24c847
B
Brody17d ago
are you able to share the repo?
GO
Ghost Order17d ago
GitHub
GitHub - GhostOrder28/inmobitas: New repo for my real estate manage...
New repo for my real estate manager project, it combines both client and server codebases to a more convenient deployment - GhostOrder28/inmobitas
B
Brody17d ago
do the client and server import stuff from one another?
GO
Ghost Order17d ago
no imports, just the build script in the client's package.json removes and creates a directory in server
B
Brody17d ago
so the server serves the client app?
GO
Ghost Order17d ago
yep, client basically just build the frontend files into a public/ dir that is located inside server/ and then the server can serve those static files
B
Brody17d ago
interesting approach can you send me your latest build logs please - https://bookmarklets.up.railway.app/log-downloader/
GO
Ghost Order17d ago
well before I had both on separated repos, but then I always ended duplicating the commit messages for both, since every change in the client repo forces also an update in the server repo because it serves the static files generated by create-react-app in client xD sure let me check the link
B
Brody17d ago
interesting in that the server is serving the client, not that you have both apps in one repo because that part is normal. in my experience its best to have the client (or frontend) serve itself and the backend serve itself (for lack of a better term)
GO
Ghost Order17d ago
oh mmm, yeah certainly that's another common approach
GO
Ghost Order17d ago
B
Brody17d ago
try adding a nixpacks.toml to your project with this in it -
[phases.install]
cmds = ['npm run install']
[phases.install]
cmds = ['npm run install']
GO
Ghost Order17d ago
ok it failed again with the same error, rimraf and react-scripts not found
B
Brody17d ago
new build logs please
GO
Ghost Order17d ago
oh right, sorry
GO
Ghost Order17d ago
B
Brody17d ago
then i might recommend moving to npm workspaces, it would help here
GO
Ghost Order17d ago
I see, well thank you for your time brody, I will read more about that or maybe I just go with the more common approach you mentioned 😅
B
Brody17d ago
haha that too
GO
Ghost Order17d ago
I don't know why but I just completely forgot that the client having its own little sever to serve just the build files is a thing xD
B
Brody17d ago
and thats easily achievable with the nixpacks.toml and Caddyfile from this repo https://github.com/brody192/create-react-app-starter
GO
Ghost Order17d ago
oh, I was thinking in creating a barebones nodejs server inside the client and serve the build files through it
B
Brody17d ago
thats also not ideal its best to use a web server as a web server, and node for node stuff
GO
Ghost Order17d ago
well that's right I will read more on nix and cady, thank you
B
Brody17d ago
you would only need to read about it if you want to learn more, those two files are drag and drop
GO
Ghost Order17d ago
yep, I always try to know understand at least the basics of the technology I use in my apps so I can customize it when I needed or have some notion of where to look at but having an easy quick start helps
B
Brody17d ago
love that attitude
GO
Ghost Order17d ago
hehe, I guess being self taught helped to build it
B
Brody17d ago
for sure
Want results from more Discord servers?
Add your server
More Posts
Fetching a file hosted on Filebrowser via Private NetworkSo I currently have a file that I am hosting using Filebrowser template. The file has a download lierror 13when i run "railway up" in the terminal of my project it says Permission denied (os error 13)Transferring a service from one project to anotherHow Can i transfer a service from a project to another project. it's a mysql database so i can't reIssue when deploying node app using dockerI'm having issues when I'm trying to deploy a node app with docker, when I build and run the image lFastAPI service health-check fails in IPV6I'm running a fastAPI service in railway. I setup a `/healthcheck` endpoint. It worked well when I eServer Response too slowI have Django, React application live on railway. I'm using Hobby plan. whenever I click through pDown only in DubaiHi Railway, Starting around 7.30 PM UTC +4, we can’t access our production instances. The URL is zeApplying chance is persistingI have this popup constantly appearing, even though nothing is being updated / changed. Anyway to geMySQL Memory UsageHey there, we just migrated to Railway and in the last 24h I saw that the memory usage is consistentRailway crashed after errors on trycatch?Is there any parameter to change in Railway so that it doesn't crash? because I'm using a trycatch tRailway having trouble connecting to local db upon deploymentHi. I recently deployed my node.js app on Railway and found out that during startup of my node.js apRedeploying service doesnt use updated Source Repo URLHi im new to railway so maybe this is a misunderstanding. I have started a project using a template rust deploy uses 10x more ram than local devhey guys, i have a rust api that is using 4-8gb of ram suddenly, now for rust that's unheard of conUnique variables for replicasHow can I assign a different token environment variable to each replica? Or have the replicas chooseDelete Strapi build and .cache foldersHello, how can I get a list of files in my railway project? I tried the command `railway run ls` buUnable to add repository to service that I'm a collaborator onI'm a collaborator on a github repo, and I'm trying to deploy a service on railway using that repo. Deploy angular project on RailwayI have angular project which I can build and run on my local machine perfectly. here is the link of Issue when deploying Typebot templateLooks like something went wrong and the train derailed... Hello, I have tried deploying both TypeboBun + Next JS 14 + Dockerfile run build failed timed outHi! The run build crashes due to timeout, please look, what's wrong with this? Service ID 9783c8b7-cExtremely expensive by previous standardsI've been using Railway for more than a year and a half, and for the first time I've seen such nonse