From f692a767f88e335d20c0b1a4b02d9adff8d3af6b Mon Sep 17 00:00:00 2001 From: liufumingren Date: Sat, 25 Jul 2026 02:15:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=8E=E6=B4=BB=E8=B7=83=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=A4=8D=E5=88=B6=20node=5Fmodules=20=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3=E5=85=A8=E9=87=8F=E4=B8=8B=E8=BD=BD=EF=BC=8Cnpm=20ins?= =?UTF-8?q?tall=20=E7=A7=92=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/deploy-remote.cjs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/script/deploy-remote.cjs b/script/deploy-remote.cjs index 7576ab1..875114c 100644 --- a/script/deploy-remote.cjs +++ b/script/deploy-remote.cjs @@ -165,7 +165,7 @@ function main() { `REMOTE_ARCHIVE=${quoteForBash(remoteArchive)}`, `ACTIVE_DIR=${quoteForBash(`${config.deployRoot}/${currentVersion}`)}`, 'cd "$TARGET_DIR"', - // 清理旧代码(保留 logs/run/tmp/.deploy 等运行时目录) + // 清理旧代码(保留 logs/run/tmp/node_modules/.deploy 等运行时目录) `find . -mindepth 1 -maxdepth 1 ${cleanupGuard} -exec rm -rf {} +`, 'tar -xzf "$REMOTE_ARCHIVE" -C "$TARGET_DIR"', 'rm -f "$REMOTE_ARCHIVE"', @@ -184,9 +184,14 @@ function main() { ' fi', ' fi', 'fi', - // 清理旧 node_modules 后全新安装,避免残留导致 semver 冲突 - 'echo "正在清理旧 node_modules ..."', - 'rm -rf "$TARGET_DIR/node_modules"', + // 从活跃版本复制 node_modules(蓝绿部署核心优化,避免每次全量下载) + 'if [ -d "$ACTIVE_DIR/node_modules" ]; then', + ' echo "正在从活跃版本 ($ACTIVE_DIR) 复制 node_modules ..."', + ' rm -rf "$TARGET_DIR/node_modules"', + ' cp -a "$ACTIVE_DIR/node_modules" "$TARGET_DIR/node_modules"', + ' echo "node_modules 复制完成"', + 'fi', + // 增量更新依赖(node_modules 已存在,仅校验变更) 'npm install --production', ].join('\n');