Files
BlogPosts/文章/技术类/Debian从零开始使用pnpm部署项目.md
zibright 404d8ed74f add post
2025-07-23 23:49:31 +08:00

49 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 安装nodejs22+环境
### 使用使用 NodeSource
首先,添加 NodeSource 的 PPA个人包存档
```shell
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
```
然后安装nodejs
```shell
apt-get install -y nodejs
```
### 使用n管理器
如果你想使用 n 管理器安装最新版本,可以先安装 n
```shell
npm install -g n
```
然后使用 n 安装 Node.js 22
```shell
n 22
```
### 验证安装
安装完成后,可以通过以下命令验证 Node.js 是否安装成功
```shell
node -v
```
## 安装pnpm
### 若已安装npm
版本不确定
```shell
npm install -g pnpm
```
### 使用独立脚本安装不用安装nodejs
Windows PowerShell
```shell
Invoke-WebRequest https://get.pnpm.io/install.ps1 -UseBasicParsing | Invoke-Expression
```
在POSIX系统上
```shell
curl -fsSL https://get.pnpm.io/install.sh | sh -
# 或者使用
# wget -qO- https://get.pnpm.io/install.sh | sh -
```
安装特定的版本
在运行安装脚本之前,你可以选择设置环境变量 PNPM_VERSION 来安装特定版本的 pnpm
```shell
curl -fsSL https://get.pnpm.io/install.sh | env PNPM_VERSION=<version> sh -
```