Deploying Turborepo project with a fastify workspace
Hey everyone! I setup a turbo repo project that has the following structure:
/apps:
- apps/api (containing fastify server and its own package.json) <- this is what i want to deploy on railway
- apps/web (containing a nextjs project) <- i want to deploy this on vercel later
/pnpm-lock.yaml (seems like the content that would normally be in the apps/api pnpm.lock file are in this)
I set the root directory in railway settings to
/apps/api
and changed the build and start commands to pnpm build
and pnpm dev
respectively.
The build fails everytime and the logs look like this:
....
I think it fails because it runs npm instead of pnpm to install. But how do i fix that?Solution:Jump to solution
with a turbo repo you wouldn't need to set a root directory in railway, you only need to have specific scripts (in the package.json at the root) to build and start each app in the turbo repo, like a
build:api
script that would only build the api app, and a start:api
script that would only start the api app (I think turbo has some type of filter flag?) then you would only need to update the build and start commands in the service settings to the specific build and start scripts that build and...9 Replies
Project ID:
dcb73c33-b411-4752-8665-de5c05f5d605
dcb73c33-b411-4752-8665-de5c05f5d605
Solution
with a turbo repo you wouldn't need to set a root directory in railway, you only need to have specific scripts (in the package.json at the root) to build and start each app in the turbo repo, like a
build:api
script that would only build the api app, and a start:api
script that would only start the api app (I think turbo has some type of filter flag?) then you would only need to update the build and start commands in the service settings to the specific build and start scripts that build and start the api appand since you now run from the root railway would properly detect pnpm and use pnpm to install your packages
wow that worked. thank you!
awesome!
Hi @Brody, i'm using the a template repo that is similarly used by @ar and i did update the script in package.json and apparently i am getting this issue on the build step
here's my package.json and railway config
there's not enough information in the screenshot as the actual error would be further up in the logs, so would you mind opening a new #✋|help thread and post your build logs that you get with this tool https://bookmarklets.up.railway.app/log-downloader/