跳到主要内容
版本:11.x

pnpm doctor

添加于: v11.14.0

对 pnpm 的安装及其运行环境执行诊断。

pnpm doctor [--offline] [--benchmark] [--json]

每项检查都会报告如何修复其发现的问题,且当任何检查失败时,该命令会以非零状态码退出。警告不会导致命令失败。

✓ Versions: pnpm 11.14.0, Node.js 22.20.0
✓ Install method: pnpm
✓ Global bin directory: /Users/example/Library/pnpm/bin
✓ Cache directory: /Users/example/Library/Caches/pnpm
✓ Store directory: /Users/example/Library/pnpm/store/v10
✓ Filesystem: available: reflink, hardlink, symlink
✓ Registry connectivity: https://registry.npmjs.org/ (128ms)
✓ Install smoke test: offline "file:" install linked its dependency

All checks passed

检查​

版本​

报告运行的 pnpm 和 Node.js 版本。

安装方法​

Reports how pnpm was installed — as the pnpm package or the @pnpm/exe standalone build — and warns when pnpm is being run by Corepack, which manages the pnpm version itself and makes pnpm self-update unavailable.

全局 bin 目录​

Checks that the directory pnpm links global executables into is on PATH and writable. If it is missing from PATH, the fix is to run pnpm setup.

缓存目录​

Checks that the cache directory is writable.

存储目录​

Checks that the store directory is writable. 没有配置存储目录时跳过。

文件系统​

基于存储卷运作的链接策略包括:引用链接(写时复制)、硬链接和符号链接。 This is what determines how packages land in node_modules and how fast an install is — a reflink or hardlink is near-free, a plain copy is not.

如果引用链接和硬链接均无法使用,检查程序会发出警告,提示安装过程将回退到复制模式,并建议将存储区放置在与项目相同的文件系统上。

注册源连接性​

向已配置的注册源发送 15 秒超时的 Ping 请求,并报告往返时间。如果无法连接到注册源或注册源返回错误状态,则操作失败;这通常指向网络、代理或身份验证配置方面的问题。

Skipped with --offline.

安装烟雾测试​

Installs a throwaway package as a file: dependency, entirely offline, in a temporary directory. 这会端到端地测试解析、存储和链接路径,并确认正在运行的二进制文件确实能够执行安装操作。

This check is always offline by construction, so --offline does not skip it.

配置项​

--offline​

跳过需要网络访问的检查。

--benchmark​

还有时间文件系统和安装检查,与每个结果一起报告持续时间。

--json​

将结果报告为 JSON。 The output is an object with a single checks array, each entry having title, status (pass, warn, or fail), and optionally detail, fix, and durationMs.

{
"checks": [
{
"title": "Filesystem",
"status": "pass",
"detail": "available: reflink, hardlink, symlink",
"durationMs": 3
}
]
}