Build Failures
Diagnosis and resolution guide for build-time and runtime errors in LenserFight.
TypeScript compilation errors
Symptoms
TS2xxxerrors duringnx buildornx typecheck- IDE shows red squiggly lines
- Build exits with non-zero code
Root cause
Type mismatches, missing imports, or stale type definitions after schema changes.
Diagnosis
bash
# Check a specific project
pnpm nx run web:typecheck
# Check all projects
pnpm nx run-many -t typecheckFixes
Regenerate Supabase types after schema changes:
bashpnpm supabase gen types typescript --local > libs/types/src/lib/database.types.tsClear TypeScript cache:
bashrm -rf tmp/ pnpm nx resetUpdate path aliases if libraries were added or renamed — check
tsconfig.base.json
Prevention
- Run
typecheckin CI before merging - Auto-generate types in CI after migration changes
Vite build failures
Symptoms
vite buildexits with errors[vite]: Rollup failed to resolve import- Chunks too large warnings
Root cause
Missing dependencies, circular imports, or misconfigured externals.
Diagnosis
bash
# Verbose build
pnpm nx run web:build --verbose
# Check dependency graph
pnpm nx graphFixes
| Error | Fix |
|---|---|
Cannot resolve module | Install missing dependency or fix import path |
Circular dependency | Restructure imports; use lazy loading |
Chunk size warning | Configure manualChunks in vite.config.ts |
Top-level await | Ensure target supports it; wrap in async function |
Prevention
- Enforce dependency boundaries with Nx module boundaries
- Run
nx affected -t buildon every PR
Hydration errors
Symptoms
- Console warning:
Hydration failed because the initial UI does not match - UI flashes or jumps on page load
Text content does not match server-rendered HTML
Root cause
Server-rendered HTML differs from client-rendered HTML, typically caused by:
- Date/time formatting differences
- Random value generation
- Browser-specific APIs used during SSR
- Conditional rendering based on
windowordocument
Diagnosis
- Open browser DevTools → Console
- Look for hydration mismatch warnings
- Identify the component causing the mismatch
Fixes
Wrap browser-only code:
tsxconst [mounted, setMounted] = useState(false); useEffect(() => setMounted(true), []); if (!mounted) return null;Avoid dynamic values in initial render:
tsx// Bad: different on server vs client const id = Math.random().toString(36); // Good: stable across renders const id = useId();Use
suppressHydrationWarningfor intentionally dynamic content:tsx<time suppressHydrationWarning>{new Date().toLocaleString()}</time>
Prevention
- Test with SSR enabled in development
- Avoid
window/documentaccess outsideuseEffect
ESLint / Prettier failures
Symptoms
nx lintfails with style violations- CI lint check fails
- Files not formatted correctly
Fixes
bash
# Auto-fix ESLint issues
pnpm nx run web:lint --fix
# Format all files
pnpm prettier --write .
# Check formatting without modifying
pnpm prettier --check .Prevention
- Enable format-on-save in your IDE
- Add pre-commit hooks with Husky + lint-staged
Nx cache issues
Symptoms
- Build produces stale output
- Tests pass locally but fail in CI
nx affectedshows no affected projects despite changes
Fixes
bash
# Clear Nx cache
pnpm nx reset
# Clear all caches
rm -rf node_modules/.vite tmp/ .nx/cache
pnpm nx resetPrevention
- Use
--skip-nx-cachewhen debugging suspicious cache hits - Clear cache after major branch merges
Next steps
- Auth Issues — authentication debugging
- Database Issues — connection and migration failures
- Workflow Issues — execution and canvas problems