Cloudflare is rebuilding node_modules in every build

Cloudflare isn't caching the node_modules folder so that consequents build run faster. I see the message Started restoring cached node modules and Finished restoring cached node modules messages on the top of all the deployment logs. But it's not working actually.

npm used to reinstall and download all the dependencies every time. Now, I am using pnpm, and the pnpm store is set to node_modules/.pnpm-store but it's redownloading and installing all the dependencies every time.

I am also using astro-imagetools which stores its cache inside node_modules/.cache/astro-imagetools which is also not working. And it's heavily impacting the build time.

I have tested both retrying deployments, adding a new commit, and triggering the deploy hooks. But none of them is able to restore the node_modules.
Was this page helpful?