fix: 서버 work-tree에서 프론트 빌드 실패(tsc 없음) 해결

서버 checkout에는 node_modules가 없어 npm run build만 실행하면 tsc를 찾지 못함.
build-frontend.sh로 npm ci 후 workspace 빌드를 수행하고,
frontend build 스크립트는 npx tsc/vite build로 통일.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Macbook
2026-06-02 23:14:16 +09:00
parent 2950442f69
commit 9c620b32e2
3 changed files with 38 additions and 1 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build": "npx tsc && npx vite build",
"preview": "vite preview"
},
"dependencies": {
+1
View File
@@ -7,6 +7,7 @@
"frontend"
],
"scripts": {
"build:frontend": "npm run build -w react-trading-chart",
"dev:app": "npm run dev -w @goldenchart/app",
"build:app": "npm run build -w @goldenchart/app",
"cap:sync": "npm run cap:sync -w @goldenchart/app",
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# 프론트엔드 프로덕션 빌드 (서버 work-tree / 로컬 공통)
# deploy.sh 는 Docker 로 빌드하므로 호스트에서 npm run build 할 때 이 스크립트를 사용한다.
set -euo pipefail
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:${PATH:-/usr/bin:/bin}"
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
FRONTEND="$ROOT/frontend"
if ! command -v npm >/dev/null 2>&1; then
echo "[build-frontend] ERROR: npm 없음. PATH에 Node/npm을 추가하세요." >&2
exit 127
fi
echo "[build-frontend] node=$(node -v) npm=$(npm -v)"
echo "[build-frontend] ROOT=$ROOT"
# npm workspaces 모노레포: 루트에서 ci 후 workspace 빌드
if [ -f "$ROOT/package.json" ] && grep -q '"workspaces"' "$ROOT/package.json" 2>/dev/null; then
if [ ! -d "$ROOT/node_modules" ]; then
echo "[build-frontend] npm ci (repo root)..."
(cd "$ROOT" && npm ci)
fi
echo "[build-frontend] npm run build -w react-trading-chart"
cd "$ROOT" && npm run build -w react-trading-chart
else
if [ ! -d "$FRONTEND/node_modules" ]; then
echo "[build-frontend] npm ci (frontend)..."
(cd "$FRONTEND" && npm ci)
fi
echo "[build-frontend] npm run build (frontend)"
cd "$FRONTEND" && npm run build
fi
echo "[build-frontend] 완료 → $FRONTEND/dist"