customize npm install command on cloudflare pages

I have a monorepo and would like to avoid installing every package on every build (even packages related to applications that are not being deployed). is there a way I can customize the npm install command to add a filter so it doesn't install unnneeded packages?
13 Replies
Oudwin
Oudwinβ€’4d ago
It seems to run it automatically after cloning the repo...
Wouter
Wouterβ€’4d ago
If you use pnpm, you can setup workspaces. And then configure watch paths in CF CI with custom run commands e.g. pnpm --filter @service run build. If you specify the root directory to your @service it should only install related packages
Oudwin
Oudwinβ€’4d ago
@Wouter | PB Hey thanks but I think I didn't explain myself very well. Yes I am doing that. But the issue is the pnpm i command It gets ran automatically by cloudflare pages that is the command I want to change I already have the build command set up like you suggest
Wouter
Wouterβ€’4d ago
Ah but if the configuration is correct, it should never install dependencies from other services afaik.
Oudwin
Oudwinβ€’4d ago
how? it runs pnpm i on the top level directory pnpm will install all packages if you do that 13:26:14.439 Preparing [email protected] for immediate activation... 13:26:16.470 Installing project dependencies: pnpm install those are the logs and this is the build command I have:
pnpm --filter @frontend... run build
pnpm --filter @frontend... run build
not sure if I am making sense @Wouter | PB
Wouter
Wouterβ€’4d ago
Ah yeah, you are right. I only looked at 15:00:29.959 dependencies: which included my services, but above in the log its getting all the node modules Haha, now you triggered me πŸ˜„ Give us the option \o/
Oudwin
Oudwinβ€’4d ago
Well for me its an even bigger deal because the app I am deploying to cloudflare doesn't need access to a private npm but another app I am not deploying to cloudflare does..... Now I have to give access to the repo to cloudflare... Or my build will fail And, it fails anyway (not sure why I'll have to figure it out) XD
Wouter
Wouterβ€’4d ago
Ohh that's crappy indeed 😦 Luckily I only have NestJS, the rest is in Rust. Don't think we're suppose to tag people but maybe we can use a once-a-year-tag-jail-card @Jacob | CI πŸ₯Ί The option to support pnpm install --filter Should decrease build times, so it's a win-win πŸ˜„
Oudwin
Oudwinβ€’4d ago
Yep! What vercel does is they allow you to override the auto configuration
Chaika
Chaikaβ€’4d ago
If you want to take over the dependency install, you can set an environment variable SKIP_DEPENDENCY_INSTALL to any value, ex: SKIP_DEPENDENCY_INSTALL = 1 , then run your own npm install or install script in the build command
κ°€λΈŒλ¦¬μ—˜ | Verzach3
Where is this on the docs?, i couldn't find it anywhere
Oudwin
Oudwinβ€’2d ago
@Chaika It doesn't seem to work for me for some reason
Chaika
Chaikaβ€’21h ago
What's your logs? This is for the v2 Build Image and doesn't effect tool installations afaik, just dependency handling
Want results from more Discord servers?
Add your server