跳至主要内容
非官方测试版翻译

本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →

共享你的缓存

Lerna 提供的计算缓存可以跨多台机器共享。你可以自行构建缓存实现,也可以使用 Nx Cloud。Nx Cloud 是一款提供快速零配置分布式缓存的应用,对开源项目和大多数闭源项目完全免费(阅读详情)。

通过交互式浏览器工作流,将你的工作区连接到 Nx Cloud 非常简单。 你只需在 lerna 工作区根目录下运行以下命令,系统就会自动打开浏览器窗口跳转到专属连接 URL:

Terminal Output
npx nx connect-to-nx-cloud

✔ Opening Nx Cloud https://cloud.nx.app/connect/abc123456 in your browser to connect your workspace.

要查看远程缓存的实际效果,请运行:

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 https://cloud.nx.app/runs/k0HDHACpL8


> 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: https://nx.app/runs/P0X6ZGTkqZ

跳过云服务

类似于 --skip-nx-cache 会指示 Nx 不使用缓存,传递 --no-cloud 将告知 Nx 不使用 Nx Cloud。你也可以在环境中将 NX_NO_CLOUD 设置为 true