Skip to content

Overview of the Nx Shared File System Cache Plugin

The @nx/shared-fs-cache plugin enables you to host your remote cache on a shared file system directory. While you're responsible for implementing the actual directory sharing mechanism, the plugin configures Nx to read from both your local cache and the shared directory.

Run the following command:

nx add @nx/shared-fs-cache

This will add the @nx/shared-fs-cache NPM package and automatically configure it for your workspace. As part of this process, you'll be guided to generate a new activation key. This is a fully automated process to register your plugin.

The key will be saved in your repository (.nx/key/key.ini) and should be committed so that every developer has access to it. If your repository is public (or in CI), you can also use an environment variable:

.env
NX_KEY=YOUR_ACTIVATION_KEY

Why require an activation key? It simply helps us know and support our users. If you prefer not to provide this information, you can also build your own cache server. Learn more.

The @nx/shared-fs-cache plugin treats your local cache directory as if it is also a remote cache directory. The local cache directory can be set using cacheDirectory in the nx.json file or the NX_CACHE_DIRECTORY environment variable. The default local cache directory is .nx/cache.

The @nx/shared-fs-cache plugin does not actually share the cache directory across your organization. You are responsible for enabling the actual sharing mechanism. If you want Nx to handle the sharing, use Nx Replay instead. Your shared file system directory might be a directory that is saved and restored by a CI provider or it could be a shared network drive.