[Support Guide] - Nx Monorepo - Site does not reflect changes after build

Last checked by Netlify Support: November 2024

The following is a bit of a niche scenario that can be challenging to debug and we felt it worthy enough to capture here as a Support Guide to hopefully help any one else who encounters it. (A Big Thank you goes to one of our customers for collaborating with us to figure this one out. :thank_you: )

Scenario:

You find that a site you build from an Nx monorepo is not publishing your changes. In the Netlify UI, the Deploy Summary and within the Deploy Log for your site shows “0 new files to upload”. So why were the new changes you just saved not picked up at build time?

Answer:

In Nx, there is a secondary cache location that lives outside of the dist folder located at node_modules/.cache/nx. Adding a --skip-nx-cache flag to the build command will allow for your changes to be picked up at build time.

Testing this out:

A test you can perform here: in your local environment, save your changes, trigger a build, and then publish a change. If this is the problem, this exercise should demonstrate the problem as well, since your local build would also be using this cache.

Parting Note:

This could occur for any data, but we have observed it before especially for data fetched via API during build from a third party service such as a CMS.

1 Like

Awesome! Just the thing I was looking for. Thank you.

glad this could be of use to you!