R
Railway12mo ago
r9d7

Failing to deploy pnpm monorepo but was successful before

Hi, I'm new to railway so please bear with me. I have a learning side project which I organized in a monorepo (https://github.com/duckradu/kameleon.social). I managed to deploy the 2 apps I have, fastify backend and solid-start frontend, about 8 days ago. Since then I have made lots of changes to my project. The biggest updates were - I noticed that I did not have a pnpm-workspace.yaml so I created one, I updated the minimum engine version required in package.json for both apps to be node >= 20 and lastly, decided to add a new railway service for a Posgres database. Now I am trying to deply the monorepo but both apps fail. Looking through the logs my best guess is that it doesn't use pnpm (anymore?).
29 Replies
Percy
Percy12mo ago
Project ID: N/A
r9d7
r9d7OP12mo ago
Project ID: 03d0bac4-b4af-4374-b8bb-5440a9efc84e
Brody
Brody12mo ago
please send the logs in a single file using this https://bookmarklets.up.railway.app/log-downloader/
r9d7
r9d7OP12mo ago
03d0bac4-b4af-4374-b8bb-5440a9efc84e Yes 2 sec
Brody
Brody12mo ago
this is your backend right?
r9d7
r9d7OP12mo ago
And the frontend project ID: a617615b-ff11-42d2-9619-2f709d9ba2ef (logs attached)
r9d7
r9d7OP12mo ago
Yes you're correct
Brody
Brody12mo ago
okay lets only focus on one service at a time for now we will focus on the backend what is the root directory of the backend service set to?
r9d7
r9d7OP12mo ago
/apps/backend And the corresponding one for the frontend app
Brody
Brody12mo ago
are these isolated apps?
r9d7
r9d7OP12mo ago
This hasn't changed since last successful deploy 8 days ago What do you mean by 'isolated'?
Brody
Brody12mo ago
if they import packages or types from one another = shared if they dont = isolated
r9d7
r9d7OP12mo ago
Ah I see No they are not The frontend imports some code from the backend, but not the other way In fact I can see the in logs for the frontend app failing to build because of that, but I didn't get too deep into it as I was trying to get at least the backend running
Brody
Brody12mo ago
once you set the root directory to /apps/frontend only the code within that folder is copied into the container, your frontend would have no way of importing from code that isnt in the container
r9d7
r9d7OP12mo ago
hmm this makes sense but makes working within a monorepo impossible
Brody
Brody12mo ago
no it doesnt, not at all, you just need to make some slight changes.
r9d7
r9d7OP12mo ago
also, why would the backend app fail in that case? the backend doesn't have the frotnend app as a dependency
Brody
Brody12mo ago
like you said, no pnpm likely
r9d7
r9d7OP12mo ago
but I was able to deploy before and my project was using pnpm from the get go
Brody
Brody12mo ago
you need to set the root directory to / (for both railway services) and give the package.json in the root specific scripts like a build:backend and start:backend and then tell each railway service to run those scripts
r9d7
r9d7OP12mo ago
sounds like a good solution, but wouldn't that still need pnpm?
Brody
Brody12mo ago
you are setting your root directory to / the root directory has a pnpm lock file thus pnpm will automatically be detected again
r9d7
r9d7OP12mo ago
Ohhh I see, thats why it didn't detect it When I last managed to deploy I didn't have a pnpm-workspace file, so each project had their own lock file. Now that I added the workspace file, pnpm created one lock file for the entire monorepo, which is located in the root directory
Brody
Brody12mo ago
yep correct
r9d7
r9d7OP12mo ago
I'm updating my project with the suggested solution rn, will come back in a sec to let you know if it worked
Brody
Brody12mo ago
sounds good
r9d7
r9d7OP12mo ago
It worked!! Thanks so much for your assistance and quick replies
Brody
Brody12mo ago
no problem!
Want results from more Discord servers?
Add your server