My web app is failing to deploy due to dependency caching issues

Error: While cloning /opt/render/project/src/npm-pkg/util-formatting/node_modules/ajv → /opt/render/project/src/apps/pods-web/node_modules/ajv ENOENT: no such file or directory, scandir '/opt/render/project/src/npm-pkg/util-formatting/node_modules/ajv’

I am able to deploy my app properly every time using Manual Deploy > Clear build cache and deploy.

However, whenever render auto deploys for me, the issue above pops up and the build fails.

Do you have any idea was the problem is or how to fix? Is there a setting that I can configure in render.yaml to just tell render to always clear build cache before deploying?

I am using yarn 3 so have SKIP_INSTALL_DEPS=true and am running a yarn install command instead as part of building. The issue may be related to this.

Hi Oliver,

Thanks for reaching out.

From the behavior you’re seeing, it sounds like there might be an issue retrieving the module from cache, since the issue seems to resolve when clearing the build cache.

Looking at the paths, it seems there’s some node_modules not in the root of the project. By default, we won’t cache the node_modules unless they are in the root directory.

However, I think you can make use of the environment variable $XDG_CACHE_HOME to set items to be cached. One of my colleagues goes into detail on this here:

Maybe this is something you can try implementing?

Hope that helps


So we have multiple node modules in 3-4 directories to cache. Are there multiple env variables? How would we handle this?

Also, at least as a stopgap, how can I just programmatically turn off caching or checking the cache during the build so it stops erroring? Basically make it so the “clear build cache & deploy” option is run by default every time a deploy occurs / new commit is added to the branch render is listening to.

That way automated deployments will function and not be a blocker, and I can try to speed it up using caching separately.

Also - what does this command actually do?
While cloning /opt/render/project/src/npm-pkg/util-formatting/node_modules/ajv → /opt/render/project/src/apps/pods-web/node_modules/ajv ENOENT: no such file or directory, scandir ‘/opt/render/project/src/npm-pkg/util-formatting/node_modules/ajv’

The ajv dependency actually does exist at the root of the workspace and we can see that the cache is large - 881mb extracted. We’re using yarn workspaces so the dependencies should be hoisted and I confirmed that it does exist at root.

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