pnpm update
Alias: up, upgrade
pnpm update aggiorna i pacchetti alla loro ultima versione in base all'intervallo specificato.
Se utilizzato senza argomenti, aggiorna tutte le dipendenze.
TL;DR#
| Comando | Significato |
|---|---|
pnpm up | Aggiorna tutte le dipendenze, aderendo agli intervalli specificati in package.json |
pnpm up --latest | Updates all dependencies to their latest versions |
pnpm up foo@2 | Aggiorna foo all'ultima versione su v2 |
pnpm up "@babel/*" | Aggiorna tutte le dipendenze nell'ambito @babel |
What an update writes#
Besides moving pnpm-lock.yaml to the newly resolved versions, pnpm update writes the new range back to the place the dependency is declared:
- In
package.json, the range is moved onto the resolved version while the operator the dependency already declared is kept, so^1.1.0stays a caret range. - A dependency declared through the
catalog:protocol is not rewritten inpackage.json. The catalog entry it points at is updated instead, inpnpm-workspace.yaml. - A dependency declared through a dist-tag, such as
"foo": "latest", keeps tracking the tag. The tag stays inpackage.jsonand only the lockfile moves to the version behind it — with--latestas well.
Pass --no-save to update the lockfile only and leave the declared ranges alone.
Selezione delle dipendenze con i modelli#
È possibile utilizzare i modelli per aggiornare dipendenze specifiche.
Aggiorna tutti i pacchetti babel:
pnpm update "@babel/*"
Aggiorna tutte le dipendenze, tranne webpack:
pnpm update "\!webpack"
I modelli possono anche essere combinati, quindi il comando successivo aggiornerà tutti gli pacchetti babel, tranne core:
pnpm update "@babel/*" "\!@babel/core"
Updating GitHub Actions#
Added in: v11.16.0
pnpm outdated can check the GitHub Actions referenced by the repository's workflow files for updates, and pnpm update can update them. This is opt-in for every command: pass --include-github-actions, or set update.githubActions to true in pnpm-workspace.yaml to enable it by default.
Updated actions are pinned to exact commit hashes, with their release tags preserved in comments:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
Checking for updates runs git ls-remote against every referenced repository. Actions whose refs cannot be read — for example, an action in a private repository — are skipped with a warning. If the actions are hosted on a different GitHub server (such as a GitHub Enterprise Server), set update.githubActionsServer (added in v11.17.0).
Opzioni#
--recursive, -r#
Esegue contemporaneamente l'aggiornamento in tutte le sottocartelle con un package.json (tranne node_modules).
Esempi di utilizzo:
pnpm --recursive update
# aggiorna tutti i pacchetti fino a 100 sottocartelle in profondità
pnpm --recursive update --depth 100
# aggiorna typescript all'ultima versione in ogni pacchetto
pnpm --recursive update typescript@latest
--latest, -L#
Update the dependencies to their latest stable version as determined by their latest tags (potentially upgrading the packages across major versions) as long as the version range specified in package.json is lower than the latest tag (i.e. it will not downgrade prereleases).
--global, -g#
Aggiorna i pacchetti globali.
--workspace#
Cerca di collegare tutti i pacchetti dallo spazio di lavoro. Le versioni vengono aggiornate per corrispondere a quelle dei pacchetti all'interno dello spazio di lavoro.
Se vengono aggiornati pacchetti specifici, il comando avrà esito negativo se una delle dipendenze aggiornate non viene trovata all'interno dello spazio di lavoro. Per esempio, il seguente comando fallisce se express non è un pacchetto dello spazio di lavoro:
pnpm up -r --workspace express
--prod, -P#
Aggiorna solo i pacchetti nelle dipendenze (dependencies) e nelle dipendenze opzionali (optionalDependencies).
--dev, -D#
Aggiorna solo i pacchetti nelle dipendenze di sviluppo (devDependencies).
--no-optional#
Non aggiornare i pacchetti nelle dipendenze opzionali (optionalDependencies).
--interactive, -i#
Mostra le dipendenze obsolete e seleziona quali aggiornare.
Since v11.21.0, combined with --global, each isolated install group is presented as one selectable item: packages that share a global installation update together as a unit.
--no-save#
Don't update the ranges in package.json.
--changeset#
Added in: v11.16.0
After the update completes, write a change intent — a changesets-compatible .changeset/*.md file — declaring a patch bump for every workspace package whose dependencies or optionalDependencies were changed by the update, and a major bump when its peerDependencies changed. Packages that consume an updated catalog entry via the catalog: protocol are included. Private packages, packages without a name, and packages listed in the ignore array of .changeset/config.json are skipped. If .changeset/config.json does not exist, a warning is printed and no changeset is generated.
Set update.changeset to true in pnpm-workspace.yaml to enable this behavior by default, and use --no-changeset to override the setting for one update.
--include-github-actions#
Added in: v11.16.0
Also update the GitHub Actions referenced by the repository's workflow files. See Updating GitHub Actions.