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
It seems to run it automatically after cloning the repo...
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
@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
Ah but if the configuration is correct, it should never install dependencies from other services afaik.
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:
not sure if I am making sense @Wouter | PBAh 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/
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
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 π
Yep!
What vercel does is they allow you to override the auto configuration
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
Where is this on the docs?, i couldn't find it anywhere
@Chaika It doesn't seem to work for me for some reason
What's your logs? This is for the v2 Build Image and doesn't effect tool installations afaik, just dependency handling