Site deploy fails unless Netlify’s build cache is cleared

Site deploy fails unless Netlify’s build cache is cleared. I looked at the 5 points mentioned in [Common Issue]: My site deploy fails unless Netlify's build cache is cleared. I don’t think points 1, 3, 4 , 5 relate to my issue and so from a process of elimination it looks like it may be point 2:

Your dependencies have binary components, which need to be rebuilt for some reason. For instance, if the version of Node.js we use to build changes, any binary modules built against the old version are unlikely to work with the new version - BUT we also may not rebuild them if they are cached already!

Things I tried:

  • migrating our build image to xenial. The error is still the same.
  • modfiying the build command from GENERATE_ENV_JS=1 yarn build to rm -rf $NETLIFY_CACHE_DIR/* && GENERATE_ENV_JS=1 yarn build but then the log threw yarn: command not found which is even more confusing. I did that in this commit. The netlify log can be found here.

Here’s an example of a build log not working unless it is cleared and retried:

It looks like it’s having trouble with installing a library so probably an issue with the node_modules directory. If that could be the issue, what would be the best way to delete node_modules from the cache?

Context: The issue showed up after updating some of our dependencies in ui/package.json of the repo.

Hey @helfi92,
Thanks a ton for sharing everything you’ve tried so far. I believe that clearing the cache with that button in the UI clears your node_modules, so you should be set there. I’d guess that the reason the build works on retry is that we’re installing newer versions of some of your dependencies, though it’s hard to know exactly which ones. If we need to keep debugging after this, it might make sense to check out what we install with the build image:

But let’s try something first! When I take a look at your logs, it looks to me like it fails on:
9:41:17 AM: Error: Cannot find module '@babel/helper-call-delegate'

Looking around, this seems to be a not uncommon problem, including in our own forum:

The most compelling suggestion I see in there is to update babel: npm install @babel/runtime@latest. Do you want to give that a shot and let us know if it fixes things for you?

Thanks for the quick reply. It turns out updating a couple of packages fixed the issue.

I’d guess that the reason the build works on retry is that we’re installing newer versions of some of your dependencies

Does a build not read yarn.lock to figure out the exact versions to download? We also had YARN_FLAGS = "--frozen-lockfile" set in netlify.toml to make sure we always download the same version. Is this not working or is Netlify only looking at the versions in package.json?

Ah, it didn’t occur to me that this could have to do with our monorepo support. Now that I see you’re using Yarn Workspaces, I think you’re probably running into this:

There’s a suggested repo structure in that thread which may or may not work for you:

I wanted to share that since it’s almost the weekend in case it’s helpful, but am also going to ask around internally if we might have other recommendations- I’ll report back here when I know more :+1: