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