fix: 5 critical bugs from Codex review

1. Windows: change "node npm.cmd" to "call npm.cmd" (npm.cmd is a
   batch wrapper, not a JS file — can't run with node.exe)
2. Build: use pnpm instead of npm (upstream build script calls pnpm
   subcommands that fail without it); add set -eo pipefail
3. Build: fail explicitly when dist/ not generated instead of || true
4. Run scripts: separate first-time onboard from normal startup
   (was running onboard every time, blocking normal launch)
5. Windows .bat: fix findstr patterns for .env dedup with /r flag
This commit is contained in:
dongsheng123132
2026-03-09 11:02:14 +08:00
parent 1b4bfb38d9
commit c556f36d92
5 changed files with 74 additions and 35 deletions

View File

@@ -34,7 +34,7 @@ if not exist "%OPENCLAW_DIR%\node_modules" (
echo (使用淘宝镜像,请稍等)
echo.
cd /d "%OPENCLAW_DIR%"
"%NODE_BIN%" "%NPM_BIN%" install --registry=https://registry.npmmirror.com
call "%NPM_BIN%" install --registry=https://registry.npmmirror.com
echo.
echo 依赖安装完成!
echo.
@@ -43,14 +43,21 @@ if not exist "%OPENCLAW_DIR%\node_modules" (
if not exist "%OPENCLAW_DIR%\dist" (
echo 首次运行,正在构建...
cd /d "%OPENCLAW_DIR%"
"%NODE_BIN%" "%NPM_BIN%" run build 2>nul
call "%NPM_BIN%" run build 2>nul
echo.
)
echo 正在启动 OpenClaw...
echo.
cd /d "%OPENCLAW_DIR%"
"%NODE_BIN%" openclaw.mjs onboard --install-daemon 2>nul || "%NODE_BIN%" openclaw.mjs 2>nul || "%NODE_BIN%" "%NPM_BIN%" start
REM 首次运行走 onboard之后直接启动
if not exist "%USERPROFILE%\.openclaw\openclaw.json" (
echo 首次配置...
"%NODE_BIN%" openclaw.mjs onboard --install-daemon
)
echo.
echo 启动 OpenClaw 服务...
"%NODE_BIN%" openclaw.mjs 2>nul || call "%NPM_BIN%" start
echo.
echo OpenClaw 已退出