Skip to main content


¥Share Your Cache

Lerna 提供的计算缓存可以分布在多台机器上。你可以构建缓存的实现或使用 Nx Cloud。Nx Cloud 是一款提供快速且零配置的分布式缓存实现的应用。对于 OSS 项目和大多数闭源项目 (在这里阅读更多内容) 来说,它是完全免费的。

¥The computation cache provided by Lerna can be distributed across multiple machines. You can either build an implementation of the cache or use Nx Cloud. Nx Cloud is an app that provides a fast and zero-config implementation of distributed caching. It's completely free for OSS projects and for most closed-sourced projects (read more here).

你可以通过运行以下命令将工作区连接到 Nx Cloud:

¥You can connect your workspace to Nx Cloud by running:

npx nx connect-to-nx-cloud
Terminal Output
✔ Enable distributed caching to make your CI faster · Yes

> NX Generating @nrwl/nx-cloud:init

UPDATE nx.json

> NX Distributed caching via Nx Cloud has been enabled

In addition to the caching, Nx Cloud provides config-free distributed execution,
UI for viewing complex runs and GitHub integration. Learn more at

Your workspace is currently unclaimed. Run details from unclaimed workspaces can be viewed on by anyone
with the link. Claim your workspace at the following link to restrict access.


¥To see the remote cache in action, run:

lerna run build --scope=header && nx reset && lerna run build --scope=header
Terminal Output
> lerna run build --scope=header

> header@0.0.0 build
> rimraf dist && rollup --config

src/index.tsx → dist...
created dist in 786ms


Lerna (powered by Nx) Successfully ran target build for project header (2s)

See logs and investigate cache misses at

> NX Resetting the Nx workspace cache and stopping the Nx Daemon.

This might take a few minutes.

> NX Daemon Server - Stopped

> NX Successfully reset the Nx workspace.

> lerna run build --scope=header [remote cache]

> header@0.0.0 build
> rimraf dist && rollup --config

src/index.tsx → dist...
created dist in 786ms


Lerna (powered by Nx) Successfully ran target build for project header (664ms)

Nx read the output from the cache instead of running the command for 1 out of 1 tasks.

Nx Cloud made it possible to reuse header:

将你的工作区连接到你的 Nx 云账户

¥Connecting Your Workspace to Your Nx Cloud Account

在工作区启用 Nx Cloud 后,你将看到以下内容:

¥After you have enabled Nx Cloud in your workspace, you will see the following:

>  NX   NOTE  Nx Cloud has been enabled

Your workspace is currently public. Anybody with code access
can view the workspace on

You can connect the workspace to your Nx Cloud account at
(You can do this later.)

单击此链接将工作区与你的 Nx Cloud 账户关联。如果你没有 Nx Cloud 账户,你可以当场创建一个。

¥Click on this link to associate the workspace with your Nx Cloud account. If you don't have an Nx Cloud account, you can create one on the spot.


¥After you claim your workspace, you will be able to manage permissions, create access tokens, set up billing, and so forth.

你还将看到一个交互式教程,帮助你探索分布式缓存和 Nx Cloud 用户界面。

¥You will also see an interactive tutorial helping you explore distributed caching and the Nx Cloud user interface.

如果你丢失此链接,你仍然可以将你的工作区连接到 Nx Cloud。转到,创建账户,然后使用 nx.json 的访问令牌连接你的工作区。

¥If you lose this link, you can still connect your workspace to Nx Cloud. Go to, create an account, and connect your workspace using the access token from nx.json.


¥Skipping Cloud

--skip-nx-cache 将指示 Nx 不要使用缓存类似,传递 --no-cloud 将告诉 Nx 不要使用 Nx Cloud。

¥Similar to how --skip-nx-cache will instruct Nx not to use the cache, passing --no-cloud will tell Nx not to use Nx Cloud.