fix: npm ci hangs — clean node_modules, add timeout, install build-essential

- rm -rf node_modules before npm ci (clean from aborted runs)
- 420s timeout on npm ci (kills if stuck on native module compilation)
- Install build-essential + python3 for better-sqlite3 native addon
- Exit with clear error if npm ci fails
This commit is contained in:
Renato
2026-07-28 00:57:05 +02:00
parent 8ed9bd83ec
commit 4e5a4eda1f
+18 -2
View File
@@ -138,13 +138,29 @@ log "Data directory ready"
STANDALONE_DIR="$INSTALL_DIR/.next/standalone"
# ── Build dependencies (build-essential for native modules) ──
if ! command -v g++ &>/dev/null; then
info "Installing build tools (needed for native modules)..."
case "$OS" in
ubuntu|debian) sudo apt install -y -qq build-essential python3 ;;
arch|endeavouros) sudo pacman -S --noconfirm base-devel python ;;
fedora|centos|rhel|*) sudo dnf groupinstall -y "Development Tools" && sudo dnf install -y python3 ;;
esac
log "Build tools installed"
fi
# ── Build (skip if already built) ──────────────────
if [ -f "$STANDALONE_DIR/server.js" ]; then
info "Build already exists — skipping"
else
info "Installing npm dependencies..."
info "Installing npm dependencies (may take 1-5 min)..."
cd "$INSTALL_DIR"
npm ci
rm -rf node_modules 2>/dev/null || true
if ! timeout 420 npm ci 2>&1; then
err "npm ci failed. Check npm registry access or try manually:"
err " cd $INSTALL_DIR && npm ci"
exit 1
fi
log "Dependencies installed"
info "Building Next.js app (this may take a few minutes)..."