Report this

What is the reason for this report?

Caching node_modules with yarn workspaces

Posted on March 2, 2022

I’m having issues with my monorepo deployment using app platform. I’m using yarn workspaces to manage dependencies. When running a new deploy and using the node_modules cache, the build fails with missing modules.

My monorepo folder structure is basically like this:

apps/
  server/
  web/
packages/
  common/
yarn.lock

I’m using turborepo to manage the build pipeline, so I use the root directory as source_dir. Each app runs as a service in my app, with build command like this yarn build --scope="<app>" --include-dependencies, which builds local dependencies before building the app.

Whenever the cache layer is restored, the following build fails with missing node_modules. I can work around this issue by simply forcing a redeploy without cache, but it is kind of tedious.

I wonder if there is some general caching issue with yarn workspaces? Haven’t been able to find anything in documentation suggesting another configuration. Could work on a reproducible repo if there is no immediate suspicion.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.