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 sax | dependencies kısmına tanımlayarak yükler |
pnpm add -D sax | devDependencies kısmına tanımlayarak yükler |
pnpm add -O sax | optionalDependencies kısmına tanımlayarak yükler |
pnpm add -g sax | Paketi global olarak yükler |
pnpm add sax@next | Paketin, next etiketli sürümünü yükler |
pnpm add sax@3.0.0 | Paketin, 3.0.0 sürümünü yükler |
Desteklenen paket kaynakları/konumları
npm kayıtlarından yükleme
pnpm add paket-ismi, paket-ismi paketinin son sürümünü varsayılan olarak npm veri tabanı'ndan yükler.
Bir çalışma alanında yürütülürse, komut önce projenin belirtilen paketi kullanıp kullanmadığını kontrol etmeye çalışır. Bu durumda, halihazırda kullanılan sürüm aralığı yüklenecektir.
Paket kurulumunu aşağıdaki alternatif örneklerle de yapabilirsin:
- tag/etiket belirterek:
pnpm add express@nightly - sürüm belirterek:
pnpm add express@1.0.0 - iki sürüm aralığı belirterek:
pnpm add express@2 react@">=0.1.0<0.2.0"
Install from the JSR registry
Added in: v10.9.0
To install packages from the JSR registry, use the jsr: protocol prefix:
pnpm add jsr:@hono/hono
pnpm add jsr:@hono/hono@4
pnpm add jsr:@hono/hono@latest
This works just like installing from npm, but tells pnpm to resolve the package through JSR instead.
Çalışma alanından/Workspace'den yükleme
Note that when adding dependencies and working within a workspace, packages will be installed from the configured sources, depending on whether or not linkWorkspacePackages is set, and use of the workspace: range protocol.
Yerel dosya sisteminden yükleme
Yerel dosya sisteminden yüklemenin iki yolu var:
- tarball dosyası kullanarak (
.tar,.tar.gzveya.tgz) - bir dizini kaynak olarak belirterek
Şu şekilde:
pnpm add ./package.tar.gz
pnpm add ./some-directory
Bir dizini kaynak olarak belirterek yükleme yaptığında, projenin node_modules klasörü içerisinde belirtilen dizin için sembolik bağ (symlink) oluşturulur. Bu işlem aynı zamanda pnpm link komutu ile aynı şekilde çalışır.
Tarball linki ile yükleme
Belirtilecek olan link, "http://" veya "https://" ile başlamalı ve indirmeye uygun bir URL olmalıdır.
Örnek kullanım:
pnpm add https://github.com/indexzero/forever/tarball/v0.5.6
Git deposundan yükleme
pnpm add <git remote url>
Installs the package from the hosted Git provider, cloning it with Git.
You may install packages from Git by:
- Latest commit from default branch:
pnpm add kevva/is-positive
- Git commit hash:
pnpm add kevva/is-positive#97edff6f525f192a3f83cea1944765f769ae2678
- Git branch:
pnpm add kevva/is-positive#master
- Git branch relative to refs:
pnpm add zkochan/is-negative#heads/canary
- Git tag:
pnpm add zkochan/is-negative#2.0.1
- V-prefixed Git tag:
pnpm add andreineculau/npm-publish-git#v0.0.7
Install from a Git repository using semver
You can specify version (range) to install using the semver: parameter. For example:
- Strict semver:
pnpm add zkochan/is-negative#semver:1.0.0
- V-prefixed strict semver:
pnpm add andreineculau/npm-publish-git#semver:v0.0.7
- Semver version range:
pnpm add kevva/is-positive#semver:^2.0.0
- V-prefixed semver version range:
pnpm add andreineculau/npm-publish-git#semver:<=v0.0.7
Install from a subdirectory of a Git repository
You may also install just a subdirectory from a Git-hosted monorepo using the path: parameter. For instance:
pnpm add RexSkz/test-git-subfolder-fetch#path:/packages/simple-react-app
Install from a Git repository via a full URL
If you want to be more explicit or are using alternative Git hosting, you might want to spell out full Git URL:
# git+ssh
pnpm add git+ssh://git@github.com:zkochan/is-negative.git#2.0.1
# https
pnpm add https://github.com/zkochan/is-negative.git#2.0.1
Install from a Git repository using hosting providers shorthand
You can use a protocol shorthand [provider]: for certain Git providers:
pnpm add github:zkochan/is-negative
pnpm add bitbucket:pnpmjs/git-resolver
pnpm add gitlab:pnpm/git-resolver
If [provider]: is omitted, it defaults to github:.
Install from a Git repository combining different parameters
It is possible to combine multiple parameters by separating them with &. This can be useful for forks of monorepos:
pnpm add RexSkz/test-git-subdir-fetch.git#beta\&path:/packages/simple-react-app
Installs from the beta branch and only the subdirectory at /packages/simple-react-app.
Parametreler
--save-prod, -P
Belirtilen paketleri dependencies kısmına tanımlayarak yükler.
--save-dev, -D
Belirtilen paketleri devDependencies kısmına tanımlayarak yükler.
--save-optional, -O
Belirtilen paketleri optionalDependencies kısmına tanımlayarak yükler.
--save-exact, -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
Paketi, global olarak yükler.
--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 onlyBuiltDependencies 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.