Langsung ke konten utama
Versi: Selanjutnya

pnpm add <pkg>

Memasang sebuah paket dan paket apa pun yang bergantung padanya. Secara asali, paket baru apa pun diinstal sebagai dependensi produksi.

SINGKATNYA

PerintahBerarti
pnpm add saxSimpan ke dependencies
pnpm add -D saxSimpan ke devDependencies
pnpm add -O saxSimpan ke optionalDependencies
pnpm add -g saxInstal paket secara global
pnpm add sax@nextMenginstal dari tanda versi next
pnpm add sax@3.0.0Tentukan versi 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)

Opsi

--save-prod, -P

Instal paket yang ditentukan sebagai reguler dependencies.

--save-dev, -D

Instal paket yang ditentukan sebagai devDependencies.

--save-optional, -O

Instal paket yang ditentukan sebagai optionalDependencies.

--save-exact, -E

Dependensi yang disimpan akan dikonfigurasikan dengan versi yang tepat daripada menggunakan operator jarak semver standar pnpm.

--save-peer

Menggunakan --save-peer akan menambahkan satu atau lebih paket ke peerDependencies dan menginstalnya sebagai dependensi dev.

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

Menambahkan dependency baru ke paket root workspace dipastikan gagal, kecuali jika flag --ignore-workspace-root-check atau -w digunakan.

Misalnya, pnpm add debug -w.

--global, -g

Instal paket secara global.

--workspace

Hanya tambahkan dependency baru jika ditemukan di workspace.

--allow-build

Added in: v10.4.0

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

Contoh:

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>

Baca lebih lanjut tentang penyaringan.

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