Caching node_modules with yarn workspaces

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:


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.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer