operations

Testing Builds Locally

⚠️ MANDATORY: Always test builds locally before committing and pushing changes. This prevents broken deployments and saves time debugging in CI/CD.

Before deploying to Vercel or Railway, you MUST test your builds locally to catch errors early.

Frontend Build Testing

Quick Build Test

cd apps/frontend
npm run build

This will:

  • Compile TypeScript
  • Run ESLint checks
  • Build the Next.js production bundle
  • Check for type errors
  • Verify all pages can be pre-rendered

What to Look For

Success: Build completes with route information showing all pages ❌ Errors: TypeScript errors, ESLint errors, or build failures

Common Issues

  1. TypeScript Errors: Fix type errors before deploying
  2. ESLint Errors: These will block Vercel builds
  3. Missing Suspense Boundaries: Pages using useSearchParams() need Suspense
  4. Unescaped Entities: Quotes and apostrophes in JSX need to be escaped

Testing the Production Build Locally

After a successful build, you can test the production build:

npm run build
npm start

Then visit http://localhost:3000 to see the production build in action.

Linting Separately

You can also run linting separately:

npm run lint

Type Checking Separately

Check TypeScript types without building:

npm run typecheck

Backend Build Testing

Quick Build Test

cd apps/backend
npm run build

This will:

  • Compile TypeScript to JavaScript
  • Check for type errors
  • Output to dist/ directory

Testing the Production Build

npm run build
npm start

The server will start on http://localhost:3001 (or the PORT from your environment).

Pre-Deployment Checklist

⚠️ REQUIRED: Complete this checklist before EVERY commit/push:

  • Frontend builds successfully (npm run build in apps/frontend)
    • Build must exit with code 0
    • No TypeScript errors
    • No ESLint errors (warnings are OK, but errors will fail)
  • Backend builds successfully (npm run build in apps/backend)
    • Build must exit with code 0
    • No TypeScript errors
  • All pages can be pre-rendered (no Suspense boundary errors)
  • All environment variables are set in deployment platforms
  • Test production build locally if possible

Do not push if builds fail! Fix errors first, then re-test.

Continuous Integration

The GitHub Actions workflows will also run builds on push:

  • Frontend: Builds and deploys to Vercel
  • Backend: Builds and type-checks (Railway auto-deploys via GitHub integration)

Tips

  1. Test locally first: Catch errors before they reach CI/CD
  2. Fix errors, not warnings: Warnings won't block deployment, but errors will
  3. Use the same Node version: Check .nvmrc files for the correct version
  4. Clean install: If you see weird errors, try rm -rf node_modules && npm install
TESTING BUILDS — Docs | HiveJournal