pnpm env <cmd>
管理 Node.js 环境。
🌐 Manages the Node.js environment.
pnpm env 不包含 Corepack 的二进制文件。如果你想使用 Corepack 来安装其他包管理器,你需要单独安装它(例如 pnpm add -g corepack)。
命令
🌐 Commands
use
安装并使用指定版本的 Node.js
🌐 Install and use the specified version of Node.js
安装 Node.js 的 LTS 版本:
🌐 Install the LTS version of Node.js:
pnpm env use --global lts
安装 Node.js v16:
🌐 Install Node.js v16:
pnpm env use --global 16
安装 Node.js 的预发布版本:
🌐 Install a prerelease version of Node.js:
pnpm env use --global nightly
pnpm env use --global rc
pnpm env use --global 16.0.0-rc.0
pnpm env use --global rc/14
安装 Node.js 的最新版本:
🌐 Install the latest version of Node.js:
pnpm env use --global latest
使用其[代号]安装 Node.js 的 LTS 版本:
🌐 Install an LTS version of Node.js using its codename:
pnpm env use --global argon
add
安装指定版本的 Node.js,但不将其激活为当前版本。
🌐 Installs the specified version(s) of Node.js without activating them as the current version.
示例:
🌐 Example:
pnpm env add --global lts 18 20.0.1
remove, rm
删除指定的 Node.js 版本。
🌐 Removes the specified version(s) of Node.js.
使用示例:
🌐 Usage example:
pnpm env remove --global 14.0.0
pnpm env remove --global 14.0.0 16.2.3
list, ls
列出本地或远程可用的 Node.js 版本。
🌐 List Node.js versions available locally or remotely.
打印本地安装的版本:
🌐 Print locally installed versions:
pnpm env list
打印远程可用的 Node.js 版本:
🌐 Print remotely available Node.js versions:
pnpm env list --remote
打印远程可用的 Node.js v16 版本:
🌐 Print remotely available Node.js v16 versions:
pnpm env list --remote 16
选项
🌐 Options
--global, -g
更改将在整个系统范围内生效。
🌐 The changes are made systemwide.