Persist npm path for user services

This commit is contained in:
武阳
2026-05-07 13:00:53 +08:00
parent b72eae5da7
commit cd4e73c159
3 changed files with 37 additions and 1 deletions
+12 -1
View File
@@ -20,8 +20,19 @@ BACKEND_HOST="${CLAW_BACKEND_HOST:-127.0.0.1}"
BACKEND_PORT="${CLAW_BACKEND_PORT:-8765}"
FRONTEND_HOST="${CLAW_FRONTEND_HOST:-0.0.0.0}"
FRONTEND_PORT="${CLAW_FRONTEND_PORT:-3000}"
NPM_BIN="${CLAW_NPM_BIN:-$(command -v npm || true)}"
if [[ -n "${CLAW_NODE_BIN_DIR:-}" ]]; then
export PATH="${CLAW_NODE_BIN_DIR}:${PATH}"
fi
if [[ -z "${NPM_BIN}" || ! -x "${NPM_BIN}" ]]; then
echo "npm not found for frontend service." >&2
echo "Run deploy again from a shell where npm is available: bash scripts/deploy-ubuntu.sh" >&2
exit 1
fi
export CLAW_API_URL="${CLAW_API_URL:-http://${BACKEND_HOST}:${BACKEND_PORT}}"
cd "${ROOT_DIR}/frontend/app"
exec npm run start -- --hostname "${FRONTEND_HOST}" --port "${FRONTEND_PORT}"
exec "${NPM_BIN}" run start -- --hostname "${FRONTEND_HOST}" --port "${FRONTEND_PORT}"