Isolated PNPM Monorepo keeps defaulting to npm
affanisautomated
PROOP

9 months ago

I have a pnpm turbo monorepo setup. There is a apps/backend and apps/frontend folder (NestJS + Vite React). The problem is, since there is no pnpm-lock file in either of these folders (only in the root), it keeps defaulting to npm.

Since there is no shared code in them, it's an isolated monorepo but I'm having problems with setting it up. Also, would like to have it done in a way that deployments get triggered only when there is code change in that specific app (apps/frontend for Vite React and apps/backend for NestJS)

Solved$10 Bounty

27 Replies

affanisautomated
PROOP

9 months ago

c243ded6-9e79-4752-857d-5b6f31fd8cc2


9 months ago

You can define a packageManager in your package.json, but if that doesn't work for you then you can also override the install and build command on Railpack via RAILPACK_INSTALL_CMD and RAILPACK_BUILD_CMD


affanisautomated
PROOP

9 months ago

I figured it out. Created a nixpacks.toml file in my backend:

[phases.setup]
nixPkgs = ["nodejs", "pnpm"]

[phases.install]
cmds = ["pnpm install"]

[phases.build]
cmds = ["pnpm run build"]

[start]
cmd = "pnpm run start:prod"

This did the job.


affanisautomated
PROOP

9 months ago

If this worked for the apps/backend, it should work for apps/frontend too


9 months ago

I suppose that works but just remember that wouldn't be cross compatible with Railpack if you ever switch in the future


affanisautomated
PROOP

9 months ago

Is one better than the other? Right now I just set out with the default configurations (AI helped me with the nixpack stuff)


9 months ago

Nixpacks is Railway's first generation builder and Railpack is the replacement second generation builder, from my understanding Nixpacks isn't being worked on anymore and Railway is actually already in the process of defaulting over to Railpack (only for some new services)


9 months ago

Setting pnpm as your packageManager in your package.json rather than using nixpacks.toml will work for both Railpack and Nixpacks so if you ever need to switch in the future then you don't need to translate Nixpacks configurations


9 months ago


affanisautomated
PROOP

9 months ago

Thank you. I'll check this out.

An unrelated question to the topic but can I not install the vector extension on my postgres instance?


9 months ago

I don't think so, but you can install a different postgres database that has the vector extension preinstalled
(made by a Railway team member)


affanisautomated
PROOP

9 months ago

I've got one more small thing. As stated that it's a pnpm monorepo structure. I've set the root directory for both as well:
apps/frontend and apps/backend
And I've set the watch paths for both like this:
apps/backend/src/** and apps/frontend/src/**

What I thought would happen is that deployment for each app would happen based on whether I have made changes in their respective paths. But right now I edited the nixpacks.toml in the backend folder and it triggered deployments for both. What am I missing here?


9 months ago

That's weird <:Thinking:1360710341239242762> I didn't think it'd do that, but I also don't use monorepo so I guess I never had a chance to find out that I'd be wrong

regardless, you can set up watch paths for each service to tell Railway which paths should change before triggering a new deployment, this will be in your service settings


affanisautomated
PROOP

9 months ago

Oh lol nvm it worked


affanisautomated
PROOP

9 months ago

I am stupid… it actually skipped 🤣


affanisautomated
PROOP

9 months ago

"No changed files matched patterns:"


9 months ago

awesome!!


9 months ago

all good to close this thread?


affanisautomated
PROOP

9 months ago

Yes. Do I close this or will an admin do that


9 months ago

I'll do that no worries


9 months ago

thank youuu


9 months ago

you will? 😆


9 months ago

trust


9 months ago


8 months ago

!s


Status changed to Solved dev 9 months ago


8 months ago

lol


8 months ago

i have to let it marinate


Loading...