|
| 1 | +# Vercel Deployment Troubleshooting Guide |
| 2 | + |
| 3 | +## Current Issue: Frontend Deployment Failing |
| 4 | + |
| 5 | +### Solution 1: Use Root Package.json (Recommended) |
| 6 | +1. **Keep the root `package.json`** I just created |
| 7 | +2. **Use the current `vercel.json`** configuration |
| 8 | +3. **In Vercel Dashboard Settings:** |
| 9 | + - Root Directory: Leave empty (use root) |
| 10 | + - Build Command: `npm run build` |
| 11 | + - Output Directory: `client/dist` |
| 12 | + - Install Command: `npm install` |
| 13 | + |
| 14 | +### Solution 2: Client Directory Only |
| 15 | +1. **Delete root `package.json`** |
| 16 | +2. **In Vercel Dashboard Settings:** |
| 17 | + - Root Directory: `client` |
| 18 | + - Build Command: `npm run build` |
| 19 | + - Output Directory: `dist` |
| 20 | + - Install Command: `npm install` |
| 21 | + |
| 22 | +### Solution 3: Alternative Configuration |
| 23 | +1. **Rename `vercel-alternative.json` to `vercel.json`** |
| 24 | +2. **Use the alternative configuration** |
| 25 | + |
| 26 | +## Manual Vercel Settings (Most Reliable) |
| 27 | + |
| 28 | +### In Vercel Dashboard: |
| 29 | +1. Go to your project settings |
| 30 | +2. Go to "Build & Development Settings" |
| 31 | +3. Set these values: |
| 32 | + ``` |
| 33 | + Framework Preset: Vite |
| 34 | + Root Directory: client |
| 35 | + Build Command: npm run build |
| 36 | + Output Directory: dist |
| 37 | + Install Command: npm install |
| 38 | + ``` |
| 39 | + |
| 40 | +### Environment Variables in Vercel: |
| 41 | +``` |
| 42 | +VITE_API_URL=https://syncruncode.onrender.com |
| 43 | +VITE_SOCKET_URL=https://syncruncode.onrender.com |
| 44 | +``` |
| 45 | + |
| 46 | +## Common Issues & Fixes |
| 47 | + |
| 48 | +### Issue 1: Build Command Not Found |
| 49 | +- **Fix**: Set Root Directory to `client` in Vercel dashboard |
| 50 | +- **Or**: Use root `package.json` with workspace setup |
| 51 | + |
| 52 | +### Issue 2: Output Directory Not Found |
| 53 | +- **Fix**: Ensure `client/dist` exists after build |
| 54 | +- **Check**: Build works locally with `cd client && npm run build` |
| 55 | + |
| 56 | +### Issue 3: Environment Variables Not Loading |
| 57 | +- **Fix**: Set variables in Vercel dashboard, not just in vercel.json |
| 58 | +- **Verify**: Variables start with `VITE_` |
| 59 | + |
| 60 | +## Testing Steps |
| 61 | +1. **Local Test**: `cd client && npm run build` |
| 62 | +2. **Check Output**: Ensure `client/dist` folder is created |
| 63 | +3. **Deploy**: Push to GitHub and check Vercel logs |
| 64 | +4. **Debug**: Check Vercel build logs for specific errors |
| 65 | + |
| 66 | +## Files Created: |
| 67 | +- `package.json` (root) - Workspace configuration |
| 68 | +- `vercel.json` - Main configuration |
| 69 | +- `vercel-alternative.json` - Alternative configuration |
| 70 | +- `vercel-simple.json` - Simple configuration |
0 commit comments