Files
ylt_diy/scripts/build.bat
user9994793890 c2dabee453 fix: 创建Windows专用批处理脚本,解决bash脚本无法运行的问题
问题:Windows PowerShell不支持bash脚本,导致 pnpm run dev 报错 "invalid option name"。

解决方案:
1. 创建Windows批处理脚本文件:
   - scripts/dev.bat:开发环境启动(含端口清除逻辑)
   - scripts/build.bat:构建脚本(安装依赖+构建+打包)
   - scripts/start.bat:生产环境启动

2. 更新package.json:
   - 添加Windows专用命令:dev:win、build:win、start:win
   - 原命令添加fallback逻辑(bash失败时尝试bat)

3. Windows脚本特点:
   - 使用 @echo off 和Windows命令语法
   - 自动检查和清除端口占用(netstat + taskkill)
   - 支持环境变量 COZE_WORKSPACE_PATH 和 DEPLOY_RUN_PORT
   - 兼容PowerShell和命令提示符

Windows用户运行方式:
- 推荐:pnpm run dev:win
- 或直接:scripts\dev.bat

Coze-Commit-Type: user
Coze-User-ID: 3722323274763196
Coze-Conversation-ID: 9894087
2026-07-08 14:03:32 +08:00

18 lines
475 B
Batchfile

@echo off
REM Windows构建脚本
REM 设置工作目录
if not defined COZE_WORKSPACE_PATH set COZE_WORKSPACE_PATH=%cd%
cd /d "%COZE_WORKSPACE_PATH%"
echo Installing dependencies...
pnpm install --prefer-frozen-lockfile --prefer-offline
echo Building the Next.js project...
pnpm next build
echo Bundling server with tsup...
pnpm tsup src/server.ts --format cjs --platform node --target node20 --outDir dist --no-splitting --no-minify
echo Build completed successfully!