Linux command
pnpm-audit 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Run security audit
pnpm audit
Fix vulnerabilities
pnpm audit --fix
JSON output
pnpm audit --json
Audit production only
pnpm audit --prod
说明
pnpm audit scans project dependencies for known security vulnerabilities using the npm advisory database. It reports affected packages, severity levels, and available patched versions. The --fix option attempts to automatically update vulnerable packages to safe versions. Use --prod or --dev to limit scanning to production or development dependencies respectively. The --audit-level option sets the minimum severity threshold for reporting (low, moderate, high, critical).
参数
- --fix
- Add overrides to package.json that pin vulnerable transitive dependencies to safe versions.
- --json
- Output the audit report as JSON.
- -P, --prod
- Audit only production dependencies (skip _devDependencies_).
- -D, --dev
- Audit only development dependencies.
- --no-optional
- Skip optional dependencies during the audit.
- --audit-level _LEVEL_
- Minimum severity to report: _low_, _moderate_, _high_, or _critical_ (default: _low_).
- --ignore _CVE_
- Suppress reporting for a specific advisory by its identifier.
- --ignore-unfixable
- Skip advisories that have no available patch.
- --ignore-registry-errors
- Exit with code 0 when the registry returns a non-200 status, only failing if real vulnerabilities are found.
FAQ
What is the pnpm-audit command used for?
pnpm audit scans project dependencies for known security vulnerabilities using the npm advisory database. It reports affected packages, severity levels, and available patched versions. The --fix option attempts to automatically update vulnerable packages to safe versions. Use --prod or --dev to limit scanning to production or development dependencies respectively. The --audit-level option sets the minimum severity threshold for reporting (low, moderate, high, critical).
How do I run a basic pnpm-audit example?
Run `pnpm audit` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --fix do in pnpm-audit?
Add overrides to package.json that pin vulnerable transitive dependencies to safe versions.