BISO Sites

Troubleshooting

Common issues and solutions for BISO Sites development.

Troubleshooting

Common issues and their solutions when developing BISO Sites.

Installation & Setup

Bun Installation Fails

Problem: Can't install Bun or getting errors

Solution:

# macOS/Linux
curl -fsSL https://bun.sh/install | bash

# Restart terminal
source ~/.bashrc  # or ~/.zshrc

# Verify installation
bun --version

Dependencies Won't Install

Problem: bun install fails or hangs

Solutions:

  1. Clear cache and retry:
rm -rf node_modules apps/*/node_modules packages/*/node_modules
rm bun.lock
bun install
  1. Check Node.js version (requires >= 18):
node --version
  1. Try with clean environment:
rm -rf ~/.bun
curl -fsSL https://bun.sh/install | bash

Development Server

Port Already in Use

Problem: Error: Port 3000 is already in use

Solutions:

  1. Kill the process:
# macOS/Linux
lsof -ti:3000 | xargs kill -9

# Windows
netstat -ano | findstr :3000
taskkill /PID <PID> /F
  1. Change the port in package.json:
{
  "scripts": {
    "dev": "next dev -p 3050"
  }
}

Hot Reload Not Working

Problem: Changes not reflecting in browser

Solutions:

  1. Hard refresh browser: Cmd+Shift+R (Mac) or Ctrl+Shift+R (Windows)
  2. Restart dev server
  3. Clear Next.js cache:
cd apps/web
rm -rf .next
bun run dev
  1. Check file is saved
  2. Ensure using correct port

Dev Server Crashes

Problem: Server crashes with memory errors

Solution:

# Increase Node memory
NODE_OPTIONS=--max-old-space-size=4096 bun run dev

Build Errors

Type Errors

Problem: TypeScript errors during build

Solutions:

  1. Generate Next.js types:
cd apps/web
bunx next build --typegen-only
  1. Check for import errors:
// ❌ Wrong
import { Button } from '@repo/ui/button'

// ✅ Correct
import { Button } from '@repo/ui/components/ui/button'
  1. Restart TypeScript server in VS Code:
  • Cmd+Shift+P → "TypeScript: Restart TS Server"

Module Not Found

Problem: Module not found: Can't resolve '@repo/...'

Solutions:

  1. Reinstall dependencies:
bun install
  1. Check tsconfig.json paths:
{
  "compilerOptions": {
    "paths": {
      "@/*": ["./src/*"],
      "@repo/ui": ["../../packages/ui"],
      "@repo/api": ["../../packages/api"]
    }
  }
}
  1. Ensure package exists in workspace

Build Fails with "Out of Memory"

Solution:

NODE_OPTIONS=--max-old-space-size=8192 bun run build

Or in package.json:

{
  "scripts": {
    "build": "NODE_OPTIONS=--max-old-space-size=8192 next build"
  }
}

Database & API

Appwrite Connection Failed

Problem: Can't connect to Appwrite

Solutions:

  1. Check environment variables:
# Verify .env.local exists
ls -la apps/web/.env.local

# Check contents
cat apps/web/.env.local
  1. Verify endpoint is accessible:
curl https://your-appwrite.com/v1/health/version
  1. Check browser console for CORS errors

  2. Verify project ID matches Appwrite dashboard

Session Not Found (401 Error)

Problem: Getting unauthorized errors

Solutions:

  1. Check cookie is set:
  • Open browser DevTools → Application → Cookies
  • Look for a_session_biso cookie
  1. Verify session client usage:
// ✅ Correct
const { account } = await createSessionClient();
const user = await account.get();

// ❌ Wrong (no session)
const { account } = await createAdminClient();
const user = await account.get();
  1. Re-login to get new session

Database Permission Denied

Problem: Can't read/write documents

Solutions:

  1. Check Appwrite collection permissions
  2. Verify user has required role
  3. Use admin client for system operations:
// In webhook/system operation
const { db } = await createAdminClient();

Payment Issues

Vipps Test Mode Not Working

Problem: Payment fails in test mode

Solutions:

  1. Verify test mode enabled:
VIPPS_TEST_MODE=true
  1. Use test card numbers:
Card: 4925 0000 0000 0004
Expiry: Any future date
CVC: Any 3 digits
  1. Check Vipps credentials are for test environment

Webhook Not Received

Problem: Order stuck in PENDING

Solutions:

  1. Check webhook URL is accessible from internet
  2. Verify webhook URL in Vipps dashboard
  3. Check server logs for incoming requests
  4. Test webhook manually:
curl -X POST http://your-domain.com/api/payment/vipps/callback?sessionId=test_123
  1. Use ngrok for local testing:
ngrok http 3000
# Use ngrok URL in Vipps dashboard

Styling Issues

Tailwind Classes Not Working

Problem: Styles not applying

Solutions:

  1. Check tailwind.config.cjs includes file:
module.exports = {
  content: [
    './src/**/*.{js,ts,jsx,tsx,mdx}',
    '../../packages/ui/components/**/*.{js,ts,jsx,tsx}',
  ],
  // ...
}
  1. Restart dev server after config changes

  2. Ensure classes are in content files (not dynamically generated):

// ❌ Wrong (dynamic classes)
className={`text-${color}-500`}

// ✅ Correct
className={color === 'blue' ? 'text-blue-500' : 'text-red-500'}

Dark Mode Not Working

Problem: Theme toggle doesn't work

Solutions:

  1. Ensure ThemeProvider is in layout:
import { ThemeProvider } from '@repo/ui/components/theme-provider';

<html suppressHydrationWarning>
  <body>
    <ThemeProvider>
      {children}
    </ThemeProvider>
  </body>
</html>
  1. Add suppressHydrationWarning to <html> tag

  2. Use theme-aware classes:

className="bg-white dark:bg-gray-900"

Git & Version Control

Merge Conflicts

Problem: Git merge conflicts

Solutions:

  1. View conflicts:
git status
  1. Resolve manually in editor, looking for:
<<<<<<< HEAD
Your changes
=======
Their changes
>>>>>>> branch-name
  1. After resolving:
git add .
git commit -m "fix: resolve merge conflicts"

Accidentally Committed Secrets

Problem: Committed API keys to repo

Solutions:

  1. Remove from history:
# Install BFG Repo Cleaner
brew install bfg

# Remove secrets
bfg --replace-text passwords.txt

# Force push (⚠️ dangerous)
git push --force
  1. Rotate all exposed secrets immediately
  2. Add to .gitignore:
.env.local
.env*.local

Performance Issues

Slow Page Load

Solutions:

  1. Use Server Components by default
  2. Minimize client-side JavaScript
  3. Optimize images:
import Image from 'next/image';

<Image
  src="/image.jpg"
  width={800}
  height={600}
  alt="Description"
/>
  1. Use loading="lazy" for images below fold

Large Bundle Size

Solutions:

  1. Analyze bundle:
cd apps/web
ANALYZE=true bun run build
  1. Use dynamic imports:
const HeavyComponent = dynamic(() => import('./HeavyComponent'), {
  loading: () => <p>Loading...</p>
});
  1. Check for duplicate dependencies

VS Code Issues

IntelliSense Not Working

Solutions:

  1. Restart TypeScript server:
  • Cmd+Shift+P → "TypeScript: Restart TS Server"
  1. Reload window:
  • Cmd+Shift+P → "Developer: Reload Window"
  1. Check .vscode/settings.json:
{
  "typescript.tsdk": "node_modules/typescript/lib",
  "typescript.enablePromptUseWorkspaceTsdk": true
}

Format on Save Not Working

Solution:

Create .vscode/settings.json:

{
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode"
}

Deployment Issues

Build Fails in Production

Solutions:

  1. Check environment variables are set
  2. Increase build timeout
  3. Use build:appwrite script for Appwrite:
bun run build:appwrite

Environment Variables Not Found

Problem: process.env.SOMETHING is undefined

Solutions:

  1. Check variable is in .env.local
  2. Restart dev server after adding variables
  3. For client-side, prefix with NEXT_PUBLIC_:
NEXT_PUBLIC_APPWRITE_ENDPOINT=...

Getting Help

If you're still stuck:

  1. Check logs - Terminal and browser console
  2. Search issues - GitHub issues or documentation
  3. Simplify - Create minimal reproduction
  4. Ask for help - Team chat or create issue
💡
Debug Mode

Set DEBUG=true in .env.local for verbose logging.

Prevention

Best Practices to Avoid Issues

  1. Keep dependencies updated - Run bun update regularly
  2. Clear cache periodically - rm -rf .next .turbo
  3. Use TypeScript strict mode - Catch errors early
  4. Test before committing - Run bun run check-types && bun run lint
  5. Read error messages - They usually tell you what's wrong
  6. Keep .env.example updated - Document required variables

Quick Fixes Checklist

When something breaks:

  • Restart dev server
  • Hard refresh browser
  • Clear Next.js cache (rm -rf .next)
  • Reinstall dependencies (rm -rf node_modules && bun install)
  • Check for type errors (bun run check-types)
  • Check browser console for errors
  • Check terminal for errors
  • Verify environment variables
  • Try in incognito/private window

Next Steps

ℹ️

Found a solution not listed here? Consider contributing it to the docs!