Isolated PNPM Monorepo keeps defaulting to npm
affanisautomated
PROOP

a year 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

a year ago

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


a year 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

a year 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

a year ago

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


a year 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

a year ago

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


a year 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)


a year 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


a year ago


affanisautomated
PROOP

a year 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?


a year 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

a year 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?


a year 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

a year ago

Oh lol nvm it worked


affanisautomated
PROOP

a year ago

I am stupid... it actually skipped 🤣


affanisautomated
PROOP

a year ago

"No changed files matched patterns:"


a year ago

awesome!!


a year ago

all good to close this thread?


affanisautomated
PROOP

a year ago

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


a year ago

I'll do that no worries


a year ago

thank youuu


a year ago

you will? 😆


a year ago

trust


a year ago


a year ago

!s


Status changed to Solved dev 11 months ago


a year ago

lol


a year ago

i have to let it marinate


Welcome!

Sign in to your Railway account to join the conversation.

Loading...