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
Percy7mo ago
Project ID: N/A
Radu Dascalu
Radu Dascalu7mo ago
Project ID: 03d0bac4-b4af-4374-b8bb-5440a9efc84e
Brody
Brody7mo ago
please send the logs in a single file using this https://bookmarklets.up.railway.app/log-downloader/
Radu Dascalu
Radu Dascalu7mo ago
03d0bac4-b4af-4374-b8bb-5440a9efc84e Yes 2 sec
Brody
Brody7mo ago
this is your backend right?
Radu Dascalu
Radu Dascalu7mo ago
And the frontend project ID: a617615b-ff11-42d2-9619-2f709d9ba2ef (logs attached)
Radu Dascalu
Radu Dascalu7mo ago
Yes you're correct
Brody
Brody7mo 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?
Radu Dascalu
Radu Dascalu7mo ago
/apps/backend And the corresponding one for the frontend app
Brody
Brody7mo ago
are these isolated apps?
Radu Dascalu
Radu Dascalu7mo ago
This hasn't changed since last successful deploy 8 days ago What do you mean by 'isolated'?
Brody
Brody7mo ago
if they import packages or types from one another = shared if they dont = isolated
Radu Dascalu
Radu Dascalu7mo 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
Brody7mo 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
Radu Dascalu
Radu Dascalu7mo ago
hmm this makes sense but makes working within a monorepo impossible
Brody
Brody7mo ago
no it doesnt, not at all, you just need to make some slight changes.
Radu Dascalu
Radu Dascalu7mo ago
also, why would the backend app fail in that case? the backend doesn't have the frotnend app as a dependency
Brody
Brody7mo ago
like you said, no pnpm likely
Radu Dascalu
Radu Dascalu7mo ago
but I was able to deploy before and my project was using pnpm from the get go
Brody
Brody7mo 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
Radu Dascalu
Radu Dascalu7mo ago
sounds like a good solution, but wouldn't that still need pnpm?
Brody
Brody7mo ago
you are setting your root directory to / the root directory has a pnpm lock file thus pnpm will automatically be detected again
Radu Dascalu
Radu Dascalu7mo 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
Brody7mo ago
yep correct
Radu Dascalu
Radu Dascalu7mo 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
Brody7mo ago
sounds good
Radu Dascalu
Radu Dascalu7mo ago
It worked!! Thanks so much for your assistance and quick replies
Brody
Brody7mo ago
no problem!