Langsung ke konten utama
Versi: 11 & 12

pnx

Aliases: pnpm dlx, pnpx

Mengambil paket dari registri tanpa menginstalnya sebagai dependensi, meng-hotloadnya, dan menjalankan perintah biner apapun yang dieksposnya.

For example, to use create-vue anywhere to bootstrap a Vue project without needing to install it under another project, you can run:

pnx create-vue my-app

This will fetch create-vue from the registry and run it with the given arguments.

Anda juga dapat menentukan versi pasti dari paket yang ingin Anda gunakan:

pnx create-vue@next my-app

The catalog: protocol is also supported, allowing you to use versions defined in your workspace catalogs:

pnx shx@catalog:

Running a package manager or a runtime

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

Naming one of the package managers pnpm provisions (npm, yarn, bun), or a runtime (node, deno, bun), provisions the real thing instead of installing the npm package that shares its name:

pnx yarn@4 install
pnx npm@11 ci
pnx bun@1.3.0 install
pnx node@22 --version

Those npm packages are either a different line of the tool or a wrapper that downloads it, so this is what naming them was always meant to do: pnx yarn@4 used to fail with a missing version, since Yarn 4 is published as @yarnpkg/cli-dist, and pnx node@22 used to run a wrapper that downloads a Node.js build rather than that release itself.

A specifier that locates a package rather than asking for a released version installs what it names, unchanged:

pnx yarn@npm:yarn@1.22.22
pnx yarn@yarnpkg/berry

--package naming a package manager picks which of its commands to run:

pnx --package npm@11 npx create-something

Pengaturan

--package <name>

Paket yang perlu diinstal sebelum menjalankan perintah.

Contoh:

pnx --package=@pnpm/meta-updater meta-updater --help
pnx --package=@pnpm/meta-updater@0 meta-updater --help

Beberapa paket dapat disediakan untuk instalasi:

pnx --package=yo --package=generator-webapp yo webapp --skip-install

--allow-build

Added in: v10.2.0

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

Contoh:

pnx --allow-build=esbuild my-bundler bundle

The actual packages executed by dlx are allowed to run postinstall scripts by default. So if in the above example my-bundler has to be built before execution, it will be built.

--shell-mode, -c

Menjalankan perintah di dalam shell. Uses /bin/sh on UNIX and \cmd.exe on Windows.

Contoh:

pnx --package cowsay --package lolcatjs -c 'echo "hi pnpm" | cowsay | lolcatjs'

--silent, -s

Hanya output dari perintah yang dieksekusi yang dicetak.

Security and trust policies

Since v11.0.0, pnx (and its pnpm dlx / pnpx aliases) honors the project-level security and trust policy settings when resolving and fetching the requested package:

This means pnx will refuse to execute freshly published or insufficiently trusted packages the same way a regular pnpm install would.