fix: detect and retry Electron binary download when npm install silently fails

npm install returns 0 even when Electron's postinstall binary download
fails, leaving node_modules/electron/dist/electron missing and causing
a blank screen with no useful error.

After npm install, explicitly check for the binary. If absent, retry
via ELECTRON_FORCE_DOWNLOAD=true node install.js. If still missing,
print a clear error and exit 1 instead of silently continuing to a
broken install.

https://claude.ai/code/session_01EyjEQLWbTXcZgbMDarf7NU
This commit is contained in:
Claude
2026-06-15 22:52:49 +00:00
parent f1febbd914
commit 4c3f5576b9
+15 -2
View File
@@ -7260,13 +7260,26 @@ PKGJSON
echo "[17/27] Installing Electron packages..."
echo "Note: npm may show deprecation warnings (safe to ignore)"
sudo -u "$KIOSK_USER" bash -lc "cd '$KIOSK_DIR' && npm install --unsafe-perm"
# Verify electron binary downloaded (npm install succeeds even if the binary download fails)
local electron_bin="$KIOSK_DIR/node_modules/electron/dist/electron"
if [[ ! -f "$electron_bin" ]]; then
log_warning "Electron binary not found after npm install — retrying download..."
sudo -u "$KIOSK_USER" bash -lc "cd '$KIOSK_DIR' && ELECTRON_FORCE_DOWNLOAD=true node node_modules/electron/install.js" || true
fi
if [[ ! -f "$electron_bin" ]]; then
log_error "Electron binary download failed. Check network connectivity and retry:"
log_error " cd $KIOSK_DIR && sudo -u $KIOSK_USER ELECTRON_FORCE_DOWNLOAD=true npm install electron --unsafe-perm"
exit 1
fi
log_success "Electron binary verified"
local sandbox="$KIOSK_DIR/node_modules/electron/dist/chrome-sandbox"
if [[ -f "$sandbox" ]]; then
sudo chown root:root "$sandbox"
sudo chmod 4755 "$sandbox"
fi
sudo -u "$KIOSK_USER" tee "$KIOSK_DIR/start.sh" > /dev/null <<'LAUNCHER'
#!/bin/bash
cd /home/kiosk/kiosk-app