pnpm dlx
别名:pnpx 是 pnpm dlx 的别名
🌐 Aliases: pnpx is an alias for pnpm dlx
从注册表中获取包,而不将其安装为依赖,热加载它,并运行它公开的任何默认命令二进制文件。
🌐 Fetches a package from the registry without installing it as a dependency, hotloads it, and runs whatever default command binary it exposes.
例如,要在任何地方使用 create-vue 来引导一个 Vue 项目,而无需在其他项目下安装它,你可以运行:
🌐 For example, to use create-vue anywhere to bootstrap a Vue project without
needing to install it under another project, you can run:
pnpm dlx create-vue my-app
这将从注册表中获取 create-vue 并使用给定的参数运行它。
🌐 This will fetch create-vue from the registry and run it with the given arguments.
你还可以指定你想要使用的软件包的确切版本:
🌐 You may also specify which exact version of the package you'd like to use:
pnpm dlx create-vue@next my-app
catalog: 协议也受支持,允许你使用工作区目录中定义的版本:
🌐 The catalog: protocol is also supported, allowing you to use versions defined in your workspace catalogs:
pnpm dlx shx@catalog:
选项
🌐 Options
--package <name>
运行命令之前要安装的包。
🌐 The package to install before running the command.
示例:
🌐 Example:
pnpm --package=@pnpm/meta-updater dlx meta-updater --help
pnpm --package=@pnpm/meta-updater@0 dlx meta-updater --help
可以提供多个包进行安装:
🌐 Multiple packages can be provided for installation:
pnpm --package=yo --package=generator-webapp dlx yo webapp --skip-install
--allow-build
新增于:v10.2.0
🌐 Added in: v10.2.0
允许在安装期间运行安装后脚本的软件包名称列表。
🌐 A list of package names that are allowed to run postinstall scripts during installation.
示例:
🌐 Example:
pnpm --allow-build=esbuild my-bundler bundle
dlx 实际执行的包默认允许运行 postinstall 脚本。所以如果在上面的例子中 my-bundler 必须在执行前构建,它将会被构建。
🌐 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
在 shell 中运行命令。在 UNIX 上使用 /bin/sh,在 Windows 上使用 \cmd.exe。
🌐 Runs the command inside of a shell. Uses /bin/sh on UNIX and \cmd.exe on Windows.
示例:
🌐 Example:
pnpm --package cowsay --package lolcatjs -c dlx 'echo "hi pnpm" | cowsay | lolcatjs'
--silent, -s
仅打印执行命令的输出。
🌐 Only the output of the executed command is printed.