安装
前言
If you don't use the standalone script or @pnpm/exe
to install pnpm, then you need to have Node.js (at least v18.12) to be installed on your system.
使用独立脚本安装
即使没有安装 Node.js,也可以使用以下脚本安装 pnpm。
Windows
使用 PowerShell:
iwr https://get.pnpm.io/install.ps1 -useb | iex
在 POSIX 系统上
curl -fsSL https://get.pnpm.io/install.sh | sh -
如果您没有安装 curl,也可以使用 wget:
wget -qO- https://get.pnpm.io/install.sh | sh -
提示
You may use the pnpm env command then to install Node.js.
In a Docker container
# 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 -
安装特定版本
Prior to running the install script, you may optionally set an env variable PNPM_VERSION
to install a specific version of pnpm:
curl -fsSL https://get.pnpm.io/install.sh | env PNPM_VERSION=<version> sh -
使用 Corepack 安装
Since v16.13, Node.js is shipping Corepack for managing package managers. 这是一项实验性功能,因此您需要通过运行如下脚本来启用它:
提示
If you have installed Node.js with pnpm env
Corepack won't be installed on your system, you will need to install it separately. See #4029.
corepack enable pnpm
如果您已经使用Homebrew安装了Node.js,您需要单独安装Corepack:
brew install corepack
这会自动将pnpm安装在您的系统上。