# @currents/nx 中文文档

规范地址：https://npmcn.com/package/%40currents/nx/

版本：2\.1\.1
npm 元数据更新时间：2026-10-30T10:16:26.808Z
中文译文更新时间：2026-11-11T05:06:25.057Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40currents/nx
原文对照：https://npmcn.com/package/%40currents/nx/?lang=original
项目主页：https://currents.dev/
源码仓库：https://github.com/currents-dev/currents-nx

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：23.3 kB，19 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：@nx/devkit  \>= 16
- 首次发布：2021-11-19T08:17:17.527Z
- 最新版本发布：2023-10-30T19:34:15.399Z
- 近 30 天下载量：15195（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：17（近 12 个月 0 个）

## 中文简介

Nx 的当前插件

## 安装

```sh
npm install @currents/nx
```

也可以使用：`pnpm add @currents/nx`、`yarn add @currents/nx`、`bun add @currents/nx`

## README

# NX 插件: 在 Cloud 中调试、 排除和记录 Cypress CI 测试

[无](https://nx.dev/) 运行 cypress 测试的插件 [当前](https://currents.dev/) 或者说 [对不起 Cypress](https://sorry-cypress.dev/)。 。 。 .

将 Cypress 和 Cypress 等替代云服务融合在一起.

该插件是针对CI环境设计的,并以无头模式运行Cypress. 请使用 `@nx/cypress` 用于在交互式模式下运行cypress.

## 示例

见 [./应用程序/网络-e2e](https://npmcn.com/package/%40currents/nx/apps/web-e2e) 例如,安装:

```sh
npx nx run web-e2e:currents --key <recordKey> --ci-build-id hello-currents-nx
```

## 设置

安装 npm 依赖性 :

```sh
npm i --save-dev @currents/nx cypress-cloud
# install cypress if needed
npm i --save-dev cypress
```

添加目标 `currents` 到您的工程配置 :

```js
{
  // ...
  "targets": {
    "currents": {
      "executor": "@currents/nx:currents",
      "options": {
        "record": true,
        "parallel": true,
        "cypressConfig": "apps/app-e2e/cypres.config.ts",
        // "key": "record key obtained from https://app.currents.dev"
        // "ciBuildId: "ci build id, read more at https://currents.dev/readme/guides/cypress-ci-build-id",
        // ... start a dev server if needed
        "devServerTarget": "my-react-app:serve",
        "testingType": "e2e"
      }
    }
  }
  // ...
```

创建新配置文件 : `currents.config.js` 旁边 `cypress.config.{jt}s`

```js
// currents.config.js
module.exports = {
  // Get the record key from https://app.currents.dev, can be any value for self-hosted instance of Sorry Cypress
  recordKey: 'XXX',
  // Set the `projectId` and the record key obtained from https://app.currents.dev or your self-hosted instance of Sorry Cypress
  projectId: 'Ij0RfK',
  // Sorry Cypress users - set the director service URL
  cloudServiceUrl: 'https://cy.currents.dev',
};
```

添加 `cypress-cloud/plugin` 改为 `cypress.config.{js|ts|mjs}`

```ts
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';
import cloudPlugin from 'cypress-cloud/plugin';

export default defineConfig({
  e2e: {
    ...nxE2EPreset(__dirname, {
      bundler: 'vite',
    }),
    specPattern: './src/**/*.cy.ts',
    setupNodeEvents(on, config) {
      return cloudPlugin(on, config);
    },
  },
});
```

## 使用量

```sh
npx nx run web-e2e:currents --key <recordKey> --ci-build-id hello-currents-nx
```

-   更新您的 `currents.config.js` 文件为 `projectId` 于 [https://app.currents.dev (英语)](https://app.currents.dev/)
-   使用在 [https://app.currents.dev (英语)](https://app.currents.dev/)

## 配置

选项可以配置在 `project.json` 在定义执行者时,或者在引用时。 更多信息, 如何配置目标和执行者 : [https://nx.dev/reference/project-confignation# 目标](https://nx.dev/reference/project-configuration#targets)。 。 。 .

见 [计划.json](https://npmcn.com/package/%40currents/nx/packages/nx/src/executors/schema.json) 的选项。 此插件使用 `cypress-cloud` 将 Cypress 整合到第三派对服务中 请参考 [圆压-云层文档](https://github.com/currents-dev/cypress-cloud) 其他细节.

### 设置记录密钥

您可以以下列方式设置记录密钥:

-   设定 `key` 属性在 `project.json`
-   设定 `recordKey` 内 `currents.config.js`
-   设置 CLI 旗 `--recordKey`
-   设定 `CURRENTS_RECORD_KEY` 环境变量

### 设置项目编号

您可以将工程编号设置如下:

-   设定 `projectId` 内 `currents.config.js`
-   设定 `CURRENTS_PROJECT_ID` 环境变量

## 移徙

### 版本 `2.0.0`

-   使用 [`cypress-cloud`](https://github.com/currents-dev/cypress-cloud) 作为管弦乐工具

### 版本 `1.0.0`

-   `@nx/cypress` 不再需要 - 插件是一个独立执行,不依赖于 `@nx/cypress`。使用可用的配置选项配置 Cypress 运行的执行.

## 释放

创建新发布 (changelog, tags + github)

```sh
# run this command, review and stage the changelog
cd ./packages/nx && npm run release
```

释放β通道 :

```sh
npx nx publish nx --tag beta --otp CODE
```

发布最新频道 :

```sh
npx nx publish nx --tag latest --otp CODE
```

## 常见问题

### @currents/nx 是什么？

Nx 的当前插件

### 如何安装 @currents/nx？

在项目目录运行 npm install @currents/nx，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@nx/devkit（ \>= 16）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @currents/nx 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @currents/nx 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @currents/nx 可以商用吗？

@currents/nx 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @currents/nx 的下载量有多少？

根据 npm 官方下载统计，@currents/nx 在 2026/10/11 – 2026/11/09 这 30 天内被下载 15,195 次，日均约 507 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @currents/nx 还在维护吗？

最新版本 2\.1\.1 发布于 2023/10/31（3 年前）；至今共发布 17 个版本，其中过去 12 个月发布了 0 个；首次发布于 2021/11/19。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

