Switch deployment to npm and sync pnpm-lock.yaml with lunar-javascript.

Use npm ci/install in deploy script and docs to avoid frozen pnpm lockfile failures on the server.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-10 20:51:35 +08:00
parent fff77dac3f
commit e44cdf913e
4 changed files with 48 additions and 21 deletions
+13 -12
View File
@@ -72,14 +72,15 @@ node -v # 应 >= v20
npm -v
```
### 3.3 安装 pnpm 与 PM2
### 3.3 安装 PM2
```bash
npm install -g pnpm pm2
pnpm -v
npm install -g pm2
pm2 -v
```
> **说明**:项目使用 **npm** + `package-lock.json` 安装依赖(无需 pnpm)。若已安装 pnpm 也可改用 `npm install`,避免 `pnpm-lock.yaml` 不同步问题。
### 3.4 安装 Git
```bash
@@ -191,13 +192,13 @@ chmod 600 .env.local
```bash
cd /opt/zhimingge
pnpm install --frozen-lockfile
npm ci || npm install
```
### 7.2 生产构建
```bash
pnpm run build
npm run build
```
构建成功后生成 `.next/standalone/` 独立运行包。
@@ -217,7 +218,7 @@ cp -r public .next/standalone/public
cp -r content .next/standalone/content
```
> **说明**:若应用从项目根目录读取 `content/`PM2 的 `cwd` 应设为 `/opt/zhimingge` 而非 standalone 子目录。当前 `ecosystem.config.cjs` 使用项目根目录 + `pnpm start`,构建后也可改用 standalone 的 `server.js`(见 7.5 备选方案)。
> **说明**:若应用从项目根目录读取 `content/`PM2 的 `cwd` 应设为 `/opt/zhimingge` 而非 standalone 子目录。当前 `ecosystem.config.cjs` 使用项目根目录 + `npm start`,构建后也可改用 standalone 的 `server.js`(见 7.5 备选方案)。
### 7.4 使用 PM2 启动(推荐方式)
@@ -330,10 +331,10 @@ cd /opt/zhimingge
git pull origin main
# 安装新依赖(如有变更)
pnpm install --frozen-lockfile
npm ci || npm install
# 重新构建
pnpm run build
npm run build
# 若使用 standalone 复制方式,重新复制 static/public/content
cp -r .next/static .next/standalone/.next/static
@@ -419,7 +420,7 @@ curl https://op.bz121.com/v1/models \
1. **`.env.local` 权限** 设为 `600`,勿提交 Git
2. **API Key** 仅保存在服务器,不要写入前端代码
3. 生产环境使用 **Nginx + HTTPS**
4. 定期 `apt update``pnpm update`
4. 定期 `apt update``npm update`
5. 若后续改为非 root 运行,创建专用用户:
```bash
@@ -437,13 +438,13 @@ chown -R zhimingge:zhimingge /opt/zhimingge
cd /opt && git clone https://git.bz121.com/dekun/zhimingge.git zhimingge
cd /opt/zhimingge
cp .env.example .env.local && nano .env.local
pnpm install --frozen-lockfile
pnpm run build
npm ci || npm install
npm run build
pm2 start ecosystem.config.cjs
pm2 save && pm2 startup
# 日常更新
cd /opt/zhimingge && git pull && pnpm install && pnpm run build && pm2 restart zhimingge
cd /opt/zhimingge && git pull && npm ci && npm run build && pm2 restart zhimingge
# 查看状态
pm2 status && curl -I http://127.0.0.1:3130