From 4c9b44288c231551119ed952ab95e6ea3bb8aeff Mon Sep 17 00:00:00 2001 From: jkooe <62494645+jkooe@users.noreply.github.com> Date: Sun, 27 Sep 2026 19:21:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(pack):=20esbuild=20=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=94=B9=E7=94=A8=E7=BB=9D=E5=AF=B9=E8=B7=AF=E5=BE=84=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8E=E4=BB=BB=E6=84=8F=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 此前 pack.mjs 用相对路径 apps/agent/dist/index.js 作为 esbuild 输入, 从项目目录外调用(node /scripts/pack.mjs)时报 Could not resolve apps/agent/dist/index.js。 改为基于 __dirname 的绝对路径;README 补充两种调用方式并注明需在项目目录执行。 验证:cd /tmp && node /scripts/pack.mjs 可正常产出 32MB 安装包 --- README.md | 13 ++++++++++++- scripts/pack.mjs | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a0b6c0e..68fb02f 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,18 @@ pnpm build **方式 A:安装包(推荐,免装 Node.js)** -1. 在控制端构建安装包:`pnpm pack:win`(产物:`release/nodeagent-win-x64.zip`) +1. 在控制端构建安装包(**需在项目目录执行**): + + ```bash + cd <项目目录> # 例如 ~/WorkBuddy/NodeAgent/nodeagent + pnpm pack:win + + # 或从任意目录调用: + node <项目目录>/scripts/pack.mjs + ``` + + 产物:`release/nodeagent-win-x64.zip`(约 32MB) + 2. 把 zip 拷到 Windows 并解压 3. 右键以**管理员**运行其中的 `install.ps1` diff --git a/scripts/pack.mjs b/scripts/pack.mjs index a568779..5a26676 100644 --- a/scripts/pack.mjs +++ b/scripts/pack.mjs @@ -68,7 +68,8 @@ async function main() { execFileSync( esbuild, [ - 'apps/agent/dist/index.js', + // 输入用绝对路径,保证从任意工作目录调用都能解析 + join(root, 'apps', 'agent', 'dist', 'index.js'), '--bundle', '--platform=node', '--target=node22',