Documentation

Lerna remote cache setup

Modern Lerna uses Nx for task scheduling and caching, so it connects through the existing Nx protocol. There is no Lerna-specific configuration beyond making your targets cacheable.

Enable caching for your tasks

Lerna delegates cache reads and writes to Nx, so caching is declared in nx.json, not in lerna.json:

{
  "targetDefaults": {
    "build": { "cache": true },
    "test": { "cache": true }
  }
}

Point Lerna at the cache

Set exactly the same two variables as for Nx, then run your tasks through Lerna as usual:

export NX_SELF_HOSTED_REMOTE_CACHE_SERVER=https://remote.cachely.dev
export NX_SELF_HOSTED_REMOTE_CACHE_ACCESS_TOKEN=<your-token>

npx lerna run build

lerna run reads and writes the Nx artifact format, so a cache filled by nx build is reused by npx lerna run build and the other way round.

Supported versions

Cachely validates Lerna 9.0.7 with Nx 22.7.5. Lerna 9 supports Nx versions from 21.5.3 up to, but not including, 23. As with Nx, every machine must resolve the same Nx version or task hashes will not match and nothing is ever shared.

Next

The Nx page covers the bare-host rule and cacheable-target details that apply here too, and troubleshooting has the Lerna-specific "runs but never hits" checklist.

Cache your Lerna tasks
Same two environment variables, same workspace token.
Start freeSee pricing