# @arcjet/runtime 中文文档

规范地址：https://npmcn.com/package/%40arcjet/runtime/

版本：1\.15\.0
npm 元数据更新时间：2026-10-28T18:47:50.818Z
中文译文更新时间：2026-11-06T14:44:11.071Z
软件包许可：Apache-2\.0

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

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

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

- 包体积（解压后）：17.4 kB，7 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=22\.21\.0 \<23 \|\| \>=24\.5\.0
- 运行依赖：0 个
- 首次发布：2024-06-10T19:53:26.283Z
- 最新版本发布：2026-10-28T18:47:49.688Z
- 近 30 天下载量：333854（2026-10-07 至 2026-11-05，npm 官方下载统计）
- 已发布版本数：65（近 12 个月 30 个）

## 中文简介

Arcjet 运行时间检测

## 安装

```sh
npm install @arcjet/runtime
```

也可以使用：`pnpm add @arcjet/runtime`、`yarn add @arcjet/runtime`、`bun add @arcjet/runtime`

## README

[![Arcjet Logo](https://arcjet.com/logo/arcjet-light-lockup-voyage-horizontal.svg)](https://arcjet.com/)

# `@arcjet/runtime`

[![npm badge](https://img.shields.io/npm/v/%40arcjet%2Fruntime?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0)](https://www.npmjs.com/package/@arcjet/runtime)

[弧喷](https://arcjet.com/) 运行时间检测.

此套件试图发现并提供 [运行时键](https://runtime-keys.proposal.wintercg.org/) 作为 定义 [冬季CG](https://wintercg.org/)。 。 。 .

-   [npm 软件包 (`@arcjet/runtime`(中文(简体) )](https://www.npmjs.com/package/@arcjet/runtime)
-   [GitHub 源代码 (`runtime/` 内 `arcjet/arcjet-js`(中文(简体) )](https://github.com/arcjet/arcjet-js/tree/main/runtime)

## 这是什么?

这是一个内部的功能,帮助我们 找出我们正在运行的平台. 这是叉子 [`unjs/std-env`](https://github.com/unjs/std-env/blob/d57a5d8/src/runtimes.ts)。 。 。 . 我们选择了叉子 这样我们就可以切掉我们不用的功能 并尽可能地保持我们的依赖树光. 我们只需要运行时间检测.

## 我什么时候用这个?

你不应该用这个,而是用 [`unjs/std-env`](https://github.com/unjs/std-env/blob/d57a5d8/src/runtimes.ts) 或其中一个 替代. 这个套装符合我们目前的需要 可能与你的不同.

## 安装

这套方案只是无害环境管理. 在 Node.js 用 npm 安装 :

```sh
npm install @arcjet/runtime
```

## 使用

```ts
import { runtime } from "@arcjet/runtime";

console.log(runtime()); // => "bun" or "node" and such
```

## API 密码

此软件包导出标识符 [`runtime`](https://npmcn.com/package/%40arcjet/runtime/#readme-runtime-1)。 。 。 . 没有默认导出 .

此套件导出 [类型脚本](https://www.typescriptlang.org/) 类型 [`Runtime`](https://npmcn.com/package/%40arcjet/runtime/#readme-runtime)。 。 。 .

### `Runtime`

该类型代表可检测到的运行时环境.

###### 类型

```ts
type Runtime = "workerd" | "deno" | "node" | "bun" | "edge-light" | "";
```

### `runtime()`

检测您的代码正在运行中的运行时环境 .

###### 回返

检测到的运行时间( E)`string`),或运行时间不能使用的空字符串 待定.

## 许可证

[Apache 许可证,2.0版本](http://www.apache.org/licenses/LICENSE-2.0) © [Arcjet实验室股份有限公司.](https://arcjet.com/)

基于 [`std-env`](https://github.com/unjs/std-env/blob/d57a5d8/src/runtimes.ts) 特许使用 [麻省理工学院](https://github.com/unjs/std-env/blob/7e8cb7b/LICENCE) Pooya Parsa(英语:Pooya Parsa). 我们的工作樱桃只选择我们需要的东西.

## 常见问题

### @arcjet/runtime 是什么？

Arcjet 运行时间检测

### 如何安装 @arcjet/runtime？

在项目目录运行 npm install @arcjet/runtime，或使用 pnpm add / yarn add / bun add。

### @arcjet/runtime 支持 TypeScript 吗？

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

### @arcjet/runtime 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @arcjet/runtime 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=22\.21\.0 \<23 \|\| \>=24\.5\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @arcjet/runtime 可以商用吗？

@arcjet/runtime 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @arcjet/runtime 的下载量有多少？

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

### @arcjet/runtime 还在维护吗？

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

