pnpm doctor

Виконує діагностику встановлення pnpm та середовища, в якому він працює.

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

Кожна перевірка містить вказівки щодо усунення виявлених проблем, і при невдачі хоча б однієї перевірки команда завершується з кодом, відмінним від нуля. Попередження не призводять до збою виконання команди.

✓ Versions: pnpm 12.3.4, Node.js 22.20.0
✓ Install method: pnpm
✓ Node.js on PATH: /Users/example/.local/share/fnm/node-versions/v22.20.0/installation/bin/node
✓ Script shell: scripts run in /bin/sh (/bin/bash), package executables in /bin/sh (/bin/bash)
✓ Global bin directory: /Users/example/Library/pnpm/bin
✓ Cache directory: /Users/example/Library/Caches/pnpm
✓ Store directory: /Users/example/Library/pnpm/store/v11
✓ Filesystem: available: reflink, hardlink, symlink
✓ Registry connectivity: https://registry.npmjs.org/ (128ms)
✓ Install smoke test: offline "file:" install linked its dependency
✓ Lifecycle scripts: an install script ran /Users/example/.local/share/fnm/node-versions/v22.20.0/installation/bin/node, a script in /Users/example/my-project ran /Users/example/.local/share/fnm/node-versions/v22.20.0/installation/bin/node

All checks passed

Перевірки#

Версії#

Повідомляє про запущені версії pnpm і Node.js.

Метод встановлення#

Reports pnpm as the install method and warns when pnpm is being run by Corepack, which manages the pnpm version itself and makes pnpm self-update unavailable.

It also warns when the pnpm found on PATH is not the one in the global bin directory. This happens when a copy from another installer, such as npm, Homebrew, Volta, or Scoop, comes first on PATH. The warning names that copy. If pnpm recognizes the installer, it gives the command that removes the copy. Otherwise it gives the PATH change that puts the global bin directory first.

Node.js on PATH#

Added in: v12.23.0

Lists the node executables on the PATH pnpm runs with, in lookup order. Lifecycle scripts run the first one, unless a directory pnpm puts ahead of them, such as node_modules/.bin, has its own node. pnpm itself does not need Node.js, but the executables in node_modules/.bin that run JavaScript do.

Warns when there is no node on PATH, and when a node entry is skipped because it is a broken link, not executable, or not a file. A version manager that relinks node while scripts run can leave such an entry behind.

Script shell#

Added in: v12.23.0

Reports the shell that runs scripts: the scriptShell, the built-in shell emulator, or the default shell (/bin/sh, or /system/bin/sh on Android). Outside Windows it also reports what /bin/sh is, because /bin/sh starts every executable in node_modules/.bin. On macOS that is the shell /private/var/select/sh links to.

Fails when the shell that runs scripts is not found.

Глобальна тека 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. When no store directory is configured, the check runs against the default store.

Файлова система#

Probes which link strategies work between the store and the project: reflink (copy-on-write), hardlink, and symlink. 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.

Якщо не працює ані reflink, ані hardlink, система попереджає, що під час встановлення буде використано копіювання, і пропонує розмістити сховище в тій самій файловій системі, що й ваші проєкти.

Звʼязок із реєстром#

Виконує тест на доступність налаштованого запису реєстру з тайм-аутом у 15 секунд і повідомляє час проходження сигналу туди й назад. Операція завершується невдачею, якщо доступ до реєстру неможливий або він повертає код помилки, що зазвичай вказує на проблеми з налаштуваннями мережі, проксі-сервера або автентифікації.

Skipped with --offline.

Тест перевірки встановлення#

Installs a throwaway package as a file: dependency, entirely offline, in a temporary directory. Це дозволяє перевірити шлях (resolve, store та link) від початку до кінця і підтвердити, що запущений бінарний файл дійсно може виконати інсталяцію.

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

Lifecycle scripts#

Added in: v12.23.0

Installs a temporary project whose postinstall script calls a dependency's executable, using the configured script shell. It then runs the same executable through pnpm exec in the current project, if there is one. Both go through the executable's node_modules/.bin shim, which has to find node on PATH. The check reports the node each run used.

If a run fails, the report includes the error and, outside Windows, the end of an sh -x trace of the shim. The trace shows the PATH the shim searched and the command it ran. A shim that finds no node is the usual cause of a script failing with exit status 127.

The run in the current project goes through pnpm exec, so the project's pnpmfile and nodeOptions apply to it as they do to pnpm exec. So do the settings passed to pnpm doctor on the command line. It does not install the project's dependencies. With --offline, it runs offline too. The whole check is skipped when there is no node on PATH.

Параметри#

--offline#

Оминати перевірки, для яких потрібен доступ до мережі.

--benchmark#

Also time the filesystem, install, and lifecycle script checks, reporting the duration alongside each result.

--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
    }
  ]
}