@b12k/gitleaks

中文文档
8.30.1-v.72发布于 2026/10/31MITES Module构建来源已验证

The missing NPM wrapper for Gitleaks

原始使用文档
文档目录5 节
  1. Installation
  2. Usage
  3. Troubleshooting
  4. Supported platforms
  5. Version

The missing npm wrapper for Gitleaks

Gitleaks - is a fast, lightweight secret scanner for git repositories.

This library is just a thin wrapper which automatically downloads the correct gitleaks binary for your platform on install and exposes it as a CLI command.

Installation

Typically installed as a dev dependency:

Local (project)

npm install --save-dev @b12k/gitleaks

Recent npm versions require approving dependency install scripts. Approve this package so its postinstall script can download the gitleaks binary:

npm approve-scripts @b12k/gitleaks
pnpm add -D --allow-build=@b12k/gitleaks @b12k/gitleaks

pnpm 11 requires the --allow-build flag so this package's postinstall script can download the gitleaks binary.

yarn add --dev @b12k/gitleaks

Global

npm install -g --allow-scripts=@b12k/gitleaks @b12k/gitleaks

Global npm installs cannot use npm approve-scripts; use --allow-scripts instead.

pnpm add -g --allow-build=@b12k/gitleaks @b12k/gitleaks

pnpm 11 requires the --allow-build flag during global install as well.

yarn global add @b12k/gitleaks

The postinstall script downloads the gitleaks binary for your platform from the official GitHub release.

If you already installed with npm or pnpm and the build was blocked, approve and rebuild it:

npm approve-scripts @b12k/gitleaks
npm rebuild @b12k/gitleaks
pnpm approve-builds @b12k/gitleaks
pnpm rebuild @b12k/gitleaks

Usage

See the gitleaks documentation for the full list of commands and flags.

Local install

npx gitleaks <command>
pnpm exec gitleaks <command>
yarn gitleaks <command>

Global install

gitleaks <command>

package.json script

{ "scripts": { "secrets": "gitleaks <command>" } }

Troubleshooting

If the binary fails to install, re-run with --foreground-scripts to see the postinstall output:

npm install --save-dev @b12k/gitleaks --foreground-scripts
pnpm add -D --allow-build=@b12k/gitleaks @b12k/gitleaks --foreground-scripts
yarn add --dev @b12k/gitleaks --foreground-scripts

Supported platforms

  • Linux — x64, arm64
  • macOS — x64, arm64
  • Windows — x64, arm64

Version

The npm package version mirrors the gitleaks release version.

To install a different gitleaks release, define it in .gitleaks-version as v1.2.3 or 1.2.3 before installing the package.

If you add or change .gitleaks-version after installing, run:

gitleaks-install

版本与发布记录

@b12k/gitleaks 共发布 73 个版本,首次发布于 2026/07/08;过去 12 个月发布了 73 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.30.1-v.72latest2026/10/312 天前
8.30.1-v.712026/10/303 天前
8.30.1-v.702026/10/294 天前
8.30.1-v.692026/10/285 天前
8.30.1-v.682026/10/2410 天前
8.30.1-v.672026/10/2311 天前

关于 @b12k/gitleaks 的常见问题

@b12k/gitleaks 是什么?

Gitleaks缺失的NPM包装器

如何安装 @b12k/gitleaks?

在项目目录运行 npm install @b12k/gitleaks,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 gitleaks、gitleaks-install,可以用 npx gitleaks 直接运行。

@b12k/gitleaks 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/b12k__gitleaks 是否存在。

@b12k/gitleaks 支持 ESM 还是 CommonJS?

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

@b12k/gitleaks 需要什么版本的 Node.js?

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

@b12k/gitleaks 可以商用吗?

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

@b12k/gitleaks 还在维护吗?

最新版本 8.30.1-v.72 发布于 2026/10/31(2 天前);至今共发布 73 个版本,其中过去 12 个月发布了 73 个;首次发布于 2026/07/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。