Skip caching when using npm ci?

Hi! We’re building a Node.js-based application on Render, and we use npm ci to install dependencies. This means that (as documented), when there’s a node_modules directory present before running npm ci, it is removed and then npm does a clean install.

So this means that Render’s cache behavior, in which it saves node_modules after a build and recovers it before the next build, is unfortunately pure overhead: we’re not using that recovered node_modules directory, which takes significant time to download from the cache.

So I want Render to not cache node_modules between builds.

However, I can’t see a clear way to disable Render’s cache behavior. Ideally, there’s just be something like cache: false in render.yaml, but that doesn’t exist. I could move the node_modules directory to somewhere that would be ignored by the cache step, but that’d break my application. Is there a way to do this?

Hi Tom,

I think your idea of installing dependencies to a directory that won’t be cached sounds like a good approach. I found this stack overflow article that outlines one approach for dealing with this on the npm side of things: https://stackoverflow.com/questions/14742553/how-to-set-custom-location-for-local-installation-of-npm-package

Is there a reason your application couldn’t be configured to also look for dependancies in a different directory?

I’d also encourage you to submit a feature request to configure the cache behavior at https://feedback.render.com/. It helps to include as much context as possible about your use case, the problem you’re looking to solve, and how you’re getting around it today to help us develop the best possible solution.

We rely heavily on customer feedback as a part of our planning and product roadmap process, so capturing interest on the feature request page is very helpful.

Regards,

Matt

Thanks - storing node modules in a place that isn’t node_modules is not supported by anything in the Node.js ecosystem and would require some messy hacks (see node_modules directory location · Issue #775 · npm/npm · GitHub ). Opened a feature request: Option to disable default cache directories like node_modules | Feature Requests | Render

Hi Tom,

Sorry we don’t have a better solution today. Thanks for taking the time to add the feedback!

Regards,

Matt

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.