pnpm add <paket-adı>

Belirtilen paketi ve bağımlı olduğu diğer paketleri yükler. Komutun varsayılan eylemi, eklemek istenilen paketi production seviyesinde, yani dependencies kısmına tanımlayarak yükler.

Kısaca;#

Komutİşlevi
pnpm add saxdependencies kısmına tanımlayarak yükler
pnpm add -D saxdevDependencies kısmına tanımlayarak yükler
pnpm add -O saxoptionalDependencies kısmına tanımlayarak yükler
pnpm add -g saxPaketi global olarak yükler
pnpm add sax@nextPaketin, next etiketli sürümünü yükler
pnpm add sax@3.0.0Paketin, 3.0.0 sürümünü yükler

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)

Adding a package manager or a runtime#

Added in: v12.0.0-rc.6 (pnpm v12 only)

Naming a package manager — npm, yarn or bun — records which one the project uses instead of installing the npm package that shares the name:

pnpm add yarn@4

writes "packageManager": "yarn@4.18.0", and every other package manager is recorded as a range in devEngines.packageManager. Naming a runtime (node, deno) records it under engines.runtime, as the explicit node@runtime:22 spelling already did — bun is both, and is declared as the project's package manager unless you ask for the runtime (pnpm add bun@runtime:1.3.0).

Globally, pnpm add -g yarn installs the current Yarn line rather than the Classic-only yarn package, and pnpm add -g node@22 installs that Node.js release rather than a wrapper that downloads one.

A specifier that locates a package rather than asking for a released version — pnpm add yarn@npm:yarn@1.22.22, pnpm add yarn@yarnpkg/berry — installs what it names, as an ordinary dependency.

Parametreler#

--save-prod, -P, -p#

Belirtilen paketleri dependencies kısmına tanımlayarak yükler.

--save-dev, -D, -d#

Belirtilen paketleri devDependencies kısmına tanımlayarak yükler.

--save-optional, -O, -o#

Belirtilen paketleri optionalDependencies kısmına tanımlayarak yükler.

--save-exact, -E, -e#

Yüklenecek olan paketleri, pnpm'in varsayılan semver aralık operatörünü kullanmadan yükler. Yani, ^ karakterini, sürüm bilgisinin başına eklenmez.

--save-peer#

Paket yüklerken --save-peer kullanıldığında yüklenecek olan paketler, peerDependencies kısmına eklenerek, bir dev dependencies'miş gibi yüklenir.

--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#

Install a package globally. See Global Packages for details.

Each space-separated package is installed into its own isolated directory. To bundle several packages into a single isolated install (so they share dependencies and are removed together), pass them as a comma-separated list, e.g. pnpm add -g eslint,prettier.

--workspace#

Belirlenen paket workspace içerisinde bulunduğu takdirde, hedef projeye dependency (bağ) olarak yükler.

--allow-build#

Added in: v10.4.0

A list of package names that are allowed to run postinstall scripts during installation.

Örnek kullanım:

pnpm --allow-build=esbuild add my-bundler

This will run esbuild's postinstall script and also add it to the allowBuilds field of pnpm-workspace.yaml. So, esbuild will always be allowed to run its scripts in the future.

--filter <paket_seçici>#

Buradan daha fazla bilgiye ulaşabilirsin.

--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.