安装指南
前提条件
如果你不使用独立脚本或 @pnpm/exe
来安装 pnpm,那么你需要在系统上安装 Node.js(至少 v18.12)。
使用独立脚本
即使你没有安装 Node.js,也可以使用以下脚本安装 pnpm。
在 Windows 上
注意
使用 PowerShell:
Invoke-WebRequest https://get.pnpm.io/install.ps1 -UseBasicParsing | Invoke-Expression
在 POSIX 系统上
curl -fsSL https://get.pnpm.io/install.sh | sh -
如果你没有安装 curl,可以使用 wget:
wget -qO- https://get.pnpm.io/install.sh | sh -
提示
然后你可以使用 pnpm env 命令来安装 Node.js。
在 Docker 容器中
# bash
wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.bashrc" SHELL="$(which bash)" bash -
# sh
wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.shrc" SHELL="$(which sh)" sh -
# dash
wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.dashrc" SHELL="$(which dash)" dash -
安装特定版本
在运行安装脚本之前,你可以选择设置环境变量 PNPM_VERSION
来安装特定版本的 pnpm:
curl -fsSL https://get.pnpm.io/install.sh | env PNPM_VERSION=<version> sh -