pnpm setup
pnpm 的独立安装脚本使用此命令。例如,在 https://get.pnpm.io/install.sh 中。
安装程序执行以下操作:
- 为 pnpm CLI 创建一个主目录
- 通过更新 shell 配置文件将 pnpm 主目录添加到
PATH - when pnpm runs as a standalone executable, installs it as a global package and writes the
pn,pnpx, andpnxscripts to$PNPM_HOME/bin
If pnpm setup cannot tell which shell configuration file to update, for example
in a container where SHELL is not set, it still installs pnpm. It then prints the
PNPM_HOME and PATH lines to add to your shell configuration yourself.
On Windows, if the registry environment values cannot be read or written,
pnpm setup still installs pnpm. It prints commands to set PNPM_HOME and
PATH in the current PowerShell session. Add these commands to your PowerShell
profile to use pnpm in future sessions without registry access.
自 v11.18.0 起,在 GitHub Actions 上运行时,pnpm setup 还会把 PNPM_HOME 和全局 bin 目录追加到 GitHub Actions 的环境文件(GITHUB_ENV 和 GITHUB_PATH)中,因此同一 job 的后续步骤可以运行 pnpm add --global 等全局命令。
提示
升级到 pnpm v11 后,运行 pnpm setup 来更新 shell 配置。在 v11 中,全局安装的二进制文件存储在 PNPM_HOME 的 bin 子目录中。