Build fails with ENOENT in a dependency during yarn install

Our site is failing to deploy PR previews. Specifically, when it runs yarn to install dependencies, we’re getting this error:

Link step
YN0001: Error: While cloning /opt/build/repo/packages/loot-core/node_modules/cross-env → /opt/build/repo/packages/desktop-client/node_modules/cross-env ENOENT: no such file or directory, scandir ‘/opt/build/repo/packages/loot-core/node_modules/cross-env’

This is happening across multiple PRs and seems to have started happening yesterday. Clearing cache and rebuilding seems to generally fix the issue, but future commits to the same branch appear to cause the issue to reoccur.

Site name: actualbudget.netlify.app. Example build log: Netlify App

Hi @j-f1 :wave:t6: I see you were able to successfully deploy. Are you still experiencing this issue?

Hi @SamO, I’m experiencing the exact same error from a week ago. I would trigger a manual clear cache + deploy and it’d eventually be gone for a while but then it’s coming back randomly. This happens on our apps linked to the same monorepo. The error itself:

6:32:31 PM: ➤ YN0001: │ Error: While cloning /opt/build/repo/apps/move-app-client/node_modules/babel-jest -> /opt/build/repo/apps/app/node_modules/babel-jest ENOENT: no such file or directory, scandir '/opt/build/repo/apps/move-app-client/node_modules/babel-jest'

Hi @sreucherand ,

You may want to check out this support guide: [Support Guide] My site deploy fails unless Netlify's build cache is cleared and see if any of the suggestions help :slight_smile:

Do let us know how it goes!

Hi @audrey,

Thank you for getting back to me.
I checked on the points you mentioned. Here is my take on these:

  1. We did not commit node_modules, we know it is bad practice.
  2. Our dependencies list may contain binary components. Though we do not update the dependencies so often, a cache clean like I did should have solve the problem but the error keeps coming back.
  3. I guess there is a mistake in the documentation, it is considered bad practice to have a yarn.lock and package-lock.json together but package.json and yarn.lock are totally fine. And I double checked, we do not mix dependencies manager, we go for yarn only.
  4. No manipulation of the node_modules directory whatsoever, and since we are not even committing it, I don’t see any impact here.
  5. We do use yarn workspaces, and we align with your specifications.
  6. Base directory is properly set.

It looks like we comply to your recommendations. I would add that we are using another CI tool in parallel of Netlify for our tests integration with very aggressive and strict cache policy and we do not experience any similar issues what so ever. So I’d be glad if you could have a look at our failing app deployments.

Hey @sreucherand,

Could you please share which site is this about?

Hey @hrishikesh,

I could see this happening on pretto-app, pretto-website, pretto-storybook. If you need the attached domains, I could give this information to you in private.

Hey @sreucherand,

Sorry for the delay. On a closer look, there is a chance this could have something to do with Yarn: [Bug?]: yarn install error ENOENT: no such file or directory · Issue #3214 · yarnpkg/berry · GitHub, [Bug?]: yarn link failing with NodeModulesLinker with workspaces · Issue #3873 · yarnpkg/berry · GitHub.

Hey @hrishikesh,

Thank you for sharing these thread, I’m preparing an update of our version of yarn and we’ll see how it behaves. I’ll keep you posted!