# @cpp-linter/clang-format 中文文档

规范地址：https://npmcn.com/package/%40cpp-linter/clang-format/

版本：23\.1\.5
npm 元数据更新时间：2026-11-07T16:33:29.594Z
中文译文更新时间：2026-11-10T21:39:49.699Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40cpp-linter/clang-format
原文对照：https://npmcn.com/package/%40cpp-linter/clang-format/?lang=original
项目主页：https://github.com/cpp-linter/clang-tools-npm#readme
源码仓库：https://github.com/cpp-linter/clang-tools-npm

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

- 包体积（解压后）：7.8 kB，6 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=18
- 运行依赖：0 个
- 首次发布：2026-10-22T17:38:27.836Z
- 最新版本发布：2026-11-07T16:33:29.204Z
- 近 30 天下载量：3569（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：23（近 12 个月 23 个）

## 中文简介

crang-format,来自LLVM的C/C++代码,作为静态二进制(LLVM 23.1.5).

## 安装

```sh
npm install @cpp-linter/clang-format
```

也可以使用：`pnpm add @cpp-linter/clang-format`、`yarn add @cpp-linter/clang-format`、`bun add @cpp-linter/clang-format`

## README

# @cpp-linter/clang-format (英语)

[![part of cpp-linter](https://img.shields.io/badge/part%20of-cpp--linter-ffc20a?labelColor=454a63)](https://cpp-linter.github.io/)

[语法](https://clang.llvm.org/docs/ClangFormat.html) 23.1.5 作为静态二进制,用于Linux,macOS和Windows在x64和arm64上.

```sh
npm install --save-dev @cpp-linter/clang-format@23
npx clang-format -i src/*.cpp
# check only, for CI
npx clang-format --dry-run --Werror src/*.cpp
```

Npm版本为LLVM版本. cang-format 输出在 LLVM 主要版本之间变化, 所以 pin one: `@cpp-linter/clang-format@23` 总是安装最新的LLVM 23发布. 老年LLVM专业 [版本数](https://www.npmjs.com/package/@cpp-linter/clang-format?activeTab=versions) 选项卡,例如 `@cpp-linter/clang-format@18`。 。 。 .

## 如何安装

此软件包每个平台有一个可选的依赖性, 例如 `@cpp-linter/clang-format-linux-x64`,npm只安装您的机器。 没有在安装时下载或运行,所以它与 `--ignore-scripts`,pnpm,Yarn,离线缓存和私人注册镜像.

## 从节点.js

```js
const clangFormat = require('@cpp-linter/clang-format');

clangFormat.binaryPath(); // absolute path of the clang-format binary
clangFormat.run(['--version']); // runs it and returns the exit code
```

## 二进制从哪里来

它们来自LLVM源由 [cpp-linter/clang-tools-静态二进制](https://github.com/cpp-linter/clang-tools-static-binaries),每个文件都有 GitHub 构建证明。 在出版之前 [发布工作流程](https://github.com/cpp-linter/clang-tools-npm) 检查每个二进制的 sha512 和 证明, 包由 GitHub Actions 发布 .

[网站](https://cpp-linter.github.io/) • 妇女 [来源](https://github.com/cpp-linter/clang-tools-npm) • 妇女 [问题](https://github.com/cpp-linter/clang-tools-npm/issues) • 妇女 [讨论情况](https://github.com/orgs/cpp-linter/discussions)

## 常见问题

### @cpp-linter/clang-format 是什么？

crang-format,来自LLVM的C/C\+\+代码,作为静态二进制\(LLVM 23\.1\.5\)\.

### 如何安装 @cpp-linter/clang-format？

在项目目录运行 npm install @cpp-linter/clang-format，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 clang-format，可以用 npx clang-format 直接运行。

### @cpp-linter/clang-format 支持 TypeScript 吗？

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

### @cpp-linter/clang-format 支持 ESM 还是 CommonJS？

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

### @cpp-linter/clang-format 需要什么版本的 Node\.js？

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

### @cpp-linter/clang-format 可以商用吗？

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

### @cpp-linter/clang-format 的下载量有多少？

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

### @cpp-linter/clang-format 还在维护吗？

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

