versioned_docs/version-10.x/cli/add.md
Installs a package and any packages that it depends on. By default, any new package is installed as a production dependency.
| Command | Meaning |
|---|---|
pnpm add sax | Save to dependencies |
pnpm add -D sax | Save to devDependencies |
pnpm add -O sax | Save to optionalDependencies |
pnpm add -g sax | Install package globally |
pnpm add sax@next | Install from the next tag |
pnpm add [email protected] | Specify version 3.0.0 |
pnpm supports installing packages from various sources. See the Supported package sources page for detailed documentation on:
Install the specified packages as regular dependencies.
Install the specified packages as devDependencies.
Install the specified packages as optionalDependencies.
Saved dependencies will be configured with an exact version rather than using pnpm's default semver range operator.
Using --save-peer will add one or more packages to peerDependencies and
install them as dev dependencies.
Added in: v10.12.1
Save the new dependency to the default catalog.
Added in: v10.12.1
Save the new dependency to the specified catalog.
Added in: v10.8.0
Save the dependency to configDependencies.
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.
Install a package globally.
Only adds the new dependency if it is found in the workspace.
Added in: v10.4.0
A list of package names that are allowed to run postinstall scripts during installation.
Example:
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.
import CpuFlag from '../settings/_cpuFlag.mdx'
<CpuFlag />import OsFlag from '../settings/_osFlag.mdx'
<OsFlag />import LibcFlag from '../settings/_libcFlag.mdx'
<LibcFlag />