Skip to main content

Local Build Verification

⚠️ IMPORTANT: Always Build Locally Before Pushing​

Building locally before pushing helps catch build errors early and prevents failed deployments.

Step-by-Step Build Process​

1. Install Dependencies​

# Ensure all dependencies are installed
yarn install

2. Run Linter​

# Check for linting errors
yarn lint

Fix any linting errors before proceeding.

3. Build the Application​

# Build the Next.js application
yarn build

What this does:

  • Compiles TypeScript
  • Validates all imports
  • Checks for build-time errors
  • Generates optimized production build
  • Validates environment variables usage

4. Verify Build Output​

After the build completes, check for:

✅ Success indicators:

✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
✓ Generating static pages
✓ Finalizing page optimization

❌ Error indicators:

  • TypeScript errors
  • Missing imports
  • Environment variable issues
  • Build-time errors

5. Test Production Build Locally (Optional)​

# Start production server locally
yarn start

Visit http://localhost:3000 to verify the production build works correctly.

Common Build Errors to Watch For​

Error TypeCauseSolution
TypeScript errorsType mismatches, missing typesFix type errors
Module not foundMissing imports or dependenciesCheck imports, run yarn install
Environment variableMissing NEXT_PUBLIC_* variablesAdd to .env.local or Vercel
Image domainUnauthorized image domainAdd to next.config.mjs
Build timeoutLarge bundle sizeOptimize imports, code splitting

Quick Build Script​

Create a pre-push hook or use this command sequence:

# Complete pre-push verification
yarn install && yarn lint && yarn build

If all commands succeed, you're ready to push!