pnpm add <pkg>
Installa un pacchetto e gli eventuali pacchetti da cui dipende. Per impostazione predefinita, qualsiasi nuovo pacchetto è installato come dipendenza di produzione.
TL;DR
| Comando | Significato |
|---|---|
pnpm add sax | Save to dependencies |
pnpm add -D sax | Save to devDependencies |
pnpm add -O sax | Save to optionalDependencies |
pnpm add -g sax | Installa il pacchetto a livello globale |
pnpm add sax@next | Install from the next tag |
pnpm add sax@3.0.0 | Specify version 3.0.0 |
Supported package sources
pnpm supports installing packages from various sources. See the Supported package sources page for detailed documentation on:
- npm registry
- JSR registry
- Workspace packages
- Local file system (tarballs and directories)
- Remote tarballs
- Git repositories (with semver, subdirectories, and more)
Opzioni
--save-prod, -P
Install the specified packages as regular dependencies.
--save-dev, -D
Install the specified packages as devDependencies.
--save-optional, -O
Install the specified packages as optionalDependencies.
--save-exact, -E
Le dipendenze salvate verranno configurate con una versione esatta invece di usare l'operatore dell'intervallo semver predefinito di pnpm.
--save-peer
Using --save-peer will add one or more packages to peerDependencies and
install them as dev dependencies.
--save-catalog
Added in: v10.12.1
Save the new dependency to the default catalog.
--save-catalog-name <catalog_name>
Added in: v10.12.1
Save the new dependency to the specified catalog.
--config
Added in: v10.8.0
Save the dependency to configDependencies.
--ignore-workspace-root-check
Adding a new dependency to the root workspace package fails, unless the
--ignore-workspace-root-check or -w flag is used.
For instance, pnpm add debug -w.
--global, -g
Installa un pacchetto a livello globale.
--workspace
Aggiunge la nuova dipendenza solo se si trova all'interno di un workspace.
--allow-build
Added in: v10.4.0
A list of package names that are allowed to run postinstall scripts during installation.
Esempio:
pnpm --allow-build=esbuild add my-bundler
This will run esbuild's postinstall script and also add it to the onlyBuiltDependencies field of pnpm-workspace.yaml. So, esbuild will always be allowed to run its scripts in the future.
--filter <package_selector>
--cpu=<name>
Added in: v10.14.0
Override CPU architecture of native modules to install. Acceptable values are same as cpu field of package.json, which comes from process.arch.
--os=<name>
Added in: v10.14.0
Override OS of native modules to install. Acceptable values are same as os field of package.json, which comes from process.platform.
--libc=<name>
Added in: v10.14.0
Override libc of native modules to install. Acceptable values are same as libc field of package.json.