pnpm install

Псевдоніми: i

pnpm install використовується для встановлення всіх залежностей проєкту.

Package manifests and archive metadata larger than 64 MiB are rejected.

У середовищі CI встановлення не вдається, якщо файл блокування присутній, але потребує оновлення. To allow lockfile updates in CI, run pnpm install --no-frozen-lockfile.

У робочому просторі, pnpm install встановлює всі залежності в усіх проєктах. If you want to disable this behavior, set the recursiveInstall setting to false.

When a workspace project changes, unchanged direct dependencies in other projects keep their locked versions if those versions still satisfy their declared ranges. Use pnpm update to request dependency updates.

Changes to a workspace package's bin field are linked into its dependents' node_modules/.bin on the next install, even with --frozen-lockfile and an unchanged lockfile.

TL;DR#

Команда Значення
pnpm i --offline Встановити оффлайн, тільки зі сховища
pnpm i --frozen-lockfile pnpm-lock.yaml не буде змінено
pnpm i --lockfile-only Оновити тільки pnpm-lock.yaml
pnpm i --dry-run Попередній перегляд змін без запису

Параметри фільтрації залежностей#

За відсутності файлу блокування pnpm має створити його, і він має бути узгодженим незалежно від фільтрації залежностей, тому запуск pnpm install --prod у теці без файлу блокування все одно призведе до розвʼязання залежностей dev, а якщо розвʼязання буде невдалим, то виникне помилка. Єдиним винятком з цього правила є залежності link:.

Без --frozen-lockfile pnpm перевірятиме застарілу інформацію з залежностей file:, тому запуск pnpm install --prod без --frozen-lockfile у середовищі, де ціль file: було видалено, призведе до помилки.

--prod, -P#

  • Стандартно: false
  • Тип: Boolean

If true, pnpm will not install any package listed in devDependencies and will remove those insofar they were already installed. Якщо false, pnpm встановить усі пакунки, з devDependencies та dependencies.

--dev, -D#

Only devDependencies are installed and dependencies are removed insofar they were already installed.

--no-optional#

optionalDependencies не буде встановлено.

--optional#

Install optionalDependencies even when the optional setting excludes them.

--no-runtime#

Skip installing runtime entries (e.g. Node.js downloaded via devEngines.runtime). Файл блокування залишається без змін, тому «заморожені» встановлення все ще перевіряються на коректність; пропускаються лише завантаження під час виконання та компіляція з бінарними файлами. A runtime that an earlier install linked is removed from node_modules.

Це корисно в матрицях CI, де середовище виконання надається ззовні (наприклад, через pnpm runtime -g set node <version>) перед запуском pnpm install.

This can also be set with runtime: false in pnpm-workspace.yaml.

Параметри#

--ignore-workspace#

Install the current project as a standalone project, without discovering a pnpm-workspace.yaml in a parent directory. The workspace's settings and other projects do not apply. See the --ignore-workspace global option.

--force#

Примусове перевстановлення залежностей: перезавантаження пакунків, змінених у сховищі, перестворення файлу блокування та/або теки модулів, створених несумісною версією pnpm. --force also lifts engineStrict.

Since v12.7.0, --force no longer installs optional dependencies whose os, cpu, or libc do not match the host. Set forceIgnoresPlatform to true to install them anyway.

--offline#

  • Стандартно: false
  • Тип: Boolean

Якщо true, pnpm буде використовувати тільки пакунки, які вже доступні в сховищі. Якщо пакунок не буде знайдено локально, встановлення завершиться невдачею.

--no-offline#

Allow network requests even when the offline setting is true.

--prefer-offline#

  • Стандартно: false
  • Тип: Boolean

Якщо true, то перевірку свіжості кешованих даних буде пропущено, але дані, яких бракує буде запитано з сервера. Щоб примусово увімкнути офлайн режим, використовуйте --offline.

--no-prefer-offline#

Don't prefer cached data even when the preferOffline setting is true.

--no-lockfile#

Не читати та не генерувати файл pnpm-lock.yaml.

--lockfile-only#

  • Стандартно: false
  • Тип: Boolean

При використанні, оновлює тільки pnpm-lock.yaml і package.json. До теки node_modules нічого не буде записано.

When resolving an unrelated change, pnpm can reuse Git commits already recorded in the lockfile for unchanged direct and transitive dependencies.

--lockfile-dir <dir>#

The directory in which pnpm-lock.yaml is created. Several projects can share one lockfile. It cannot be combined with --global.

--dry-run#

Виконує повне визначення залежностей та повідомляє, що зміниться під час реальної інсталяції, не записуючи нічого на диск. No lockfile, manifest, or node_modules changes are saved.

Пробний запуск завершується з кодом 0, навіть якщо повідомляється, що під час реальної інсталяції файл блокування буде оновлено.

--dry-run cannot be used with a configured pnpr server, because that install path resolves and links through the server.

--fix-lockfile#

Автоматично виправити пошкоджені записи файлу блокування.

--update-checksums#

Re-resolve every locked package and record the integrity the registry reports now in pnpm-lock.yaml. Use it when a registry rewrote its tarballs, or after a registry starts serving tars.

By default, an integrity mismatch is a hard failure: pnpm install exits with ERR_PNPM_TARBALL_INTEGRITY rather than silently re-resolving from the registry and overwriting the locked integrity. Це захищає проєкти, які поширюють зафіксований файл блокування, від компрометованого реєстру, проксі-сервера або перевиданої версії, що замінює вміст на чистій машині на такий, що контролюється зловмисником.

--update-checksums is the narrowly-scoped opt-in for the legitimate case (e.g. a registry rewrote its tarballs and you've verified the new bytes are correct). Коли оминання вступає в дію, на екрані все одно з’являється попередження, щоб цю операцію можна було перевірити.

--force and pnpm update deliberately do not bypass the integrity check. --frozen-lockfile is unchanged, and --fix-lockfile keeps its documented purpose (filling in missing lockfile entries) and is also not a bypass.

--frozen-lockfile#

  • Стандартно:
    • Для не-CI: false
    • Для CI: true, якщо присутній файл блокування
  • Тип: Boolean

Якщо true, pnpm не генерує файл блокування та не виконує інсталяцію, якщо файл блокування не синхронізований з маніфестом / потрібне оновлення або файл блокування відсутній.

Цей параметр стандартно дорівнює true в CI середовищах. pnpm detects a CI environment with the same rules as the ci-info package. Set CI=false to turn detection off.

When verifying a locked tarball online, pnpm asks the registry for fresh package metadata once if the cached metadata omits the locked version.

--no-frozen-lockfile#

Allows lockfile updates during installation. This is the inverse of --frozen-lockfile.

--prefer-frozen-lockfile#

Use the existing lockfile without re-resolving, even when the manifest might have changed. The inverse is --no-prefer-frozen-lockfile, which always re-resolves against the registry. See preferFrozenLockfile.

--ignore-manifest-check#

Skip the check that pnpm-lock.yaml is up to date with package.json under --frozen-lockfile. Use it only when you just wrote the lockfile yourself.

--trust-lockfile#

Skip verifying the lockfile against supply-chain policies. --no-trust-lockfile verifies it even when the configuration trusts it. See trustLockfile.

--auto-dedupe#

Deduplicate compatible dependency versions during installation. --no-auto-dedupe turns it off when the configuration turns it on. See autoDedupe.

--minimum-release-age <minutes>#

Added in: v12.23.0

Sets minimumReleaseAge for this run, overriding the configured value. The value is in minutes. As with a configured value, it turns on minimumReleaseAgeStrict unless that setting is configured. A value that is not a non-negative number is an error.

--minimum-release-age-exclude <package-spec>#

Added in: v12.23.0

Sets minimumReleaseAgeExclude for this run, replacing the configured list. Repeat the option to exclude several packages:

pnpm install --minimum-release-age 1440 --minimum-release-age-exclude react --minimum-release-age-exclude webpack@5.98.0

--merge-git-branch-lockfiles#

Обʼєднання всіх файлів блокування гілок git. [Читайте більше про файли блокування гілок git.](.. /git_branch_lockfiles)

--merge-git-branch-lockfiles-branch-pattern <glob>#

Merge the git branch lockfiles when the current branch matches the pattern. The option can be repeated. See mergeGitBranchLockfilesBranchPattern.

--reporter=<name>#

  • Стандартно:
    • Для TTY stdout: default
    • Для non-TTY stdout: append-only
  • Тип: default, append-only, ndjson, silent

Дозволяє вибрати репортера, який записуватиме у термінал налагоджувальну інформацію про хід встановлення.

  • silent — у консоль не виводиться жодних даних, навіть фатальних помилок
  • default — стандартний репортер, коли stdout є TTY
  • append-only — результат завжди додається в кінець. Жодні маніпуляції з курсором не виконуються
  • ndjson — найдокладніший репортер. Prints all logs in ndjson format. Fatal error records include the error code. Dependency resolution errors also include the parent packages in pkgsStack.

Якщо ви хочете змінити тип інформації, що виводиться, скористайтеся параметром loglevel.

--shamefully-hoist#

  • Стандартно: false
  • Тип: Boolean

Створює пласку структуру node_modules, подібну до структури npm або yarn. ПОПЕРЕДЖЕННЯ: це вкрай не рекомендується.

--ignore-scripts#

  • Стандартно: false
  • Тип: Boolean

Не виконувати будь-які скрипти, визначені в package.json проєкту та його залежностях.

--no-ignore-scripts#

Run lifecycle scripts even when the ignoreScripts setting is true.

--ignore-pnpmfile#

Don't load the hooks in .pnpmfile.cjs, including the pnpmfiles of config dependencies.

--node-linker <linker>#

  • Тип: isolated, hoisted, pnp

Override the nodeLinker setting for this install.

--frozen-store#

Open the store read-only and skip all store writes, for a store on a read-only filesystem. Use it with --offline --frozen-lockfile. --no-frozen-store allows store writes when the configuration turns the read-only store on. See frozenStore.

--network-concurrency <number>#

Override the networkConcurrency setting.

--fetch-timeout <ms>#

Override the fetchTimeout setting.

--fetch-warn-timeout-ms <ms>#

Override the fetchWarnTimeoutMs setting.

--fetch-min-speed-ki-bps <number>#

Override the fetchMinSpeedKiBps setting.

--user-agent <string>#

The User-Agent header to send with registry requests.

--pnpr-server <url>#

Override the pnprServer setting.

--allow-build#

Added in: v12.7.0

Allow the named package to run its lifecycle scripts during this install, and record it in the allowBuilds field of pnpm-workspace.yaml so it stays allowed. Prefix a name with ! to deny its scripts instead. The option can be repeated or, since v12.23.0, take a comma-separated list:

pnpm install --allow-build=esbuild --allow-build='!core-js'

Pass a git or tarball key in its own --allow-build. A value that contains one is not split at its commas.

The quotes keep a POSIX shell from treating ! as history expansion. In Windows cmd.exe, leave them out.

writes:

pnpm-workspace.yaml
allowBuilds:
  esbuild: true
  core-js: false

--filter <package_selector>#

Читайте більше про фільтрування.

--cpu=<name>#

Перевизначити архітектуру CPU нативних модулів для встановлення. Прийнятні значення такі самі, як поле cpu у файлі package.json, яке походить із process.arch.

--os=<name>#

Перевизначити OS нативних модулів для встановлення. Прийнятні значення такі самі, як поле os у файлі package.json, яке походить із process.platform.

--libc=<name>#

Перевизначити libc нативних модулів для встановлення. Прийнятні значення такі самі, як поле libc у файлі package.json.