Skip to content

Commit 6027c6e

Browse files
Add comprehensive Vercel deployment fixes and troubleshooting guide
1 parent c5cc044 commit 6027c6e

4 files changed

Lines changed: 128 additions & 4 deletions

File tree

VERCEL_TROUBLESHOOTING.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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

package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "syncruncode",
3+
"version": "1.0.0",
4+
"description": "SyncRunCode - Online Code Compiler",
5+
"private": true,
6+
"scripts": {
7+
"build": "cd client && npm run build",
8+
"install": "cd client && npm install",
9+
"dev": "cd client && npm run dev"
10+
},
11+
"workspaces": [
12+
"client"
13+
]
14+
}

vercel-alternative.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"version": 2,
3+
"name": "syncruncode",
4+
"builds": [
5+
{
6+
"src": "client/package.json",
7+
"use": "@vercel/static-build",
8+
"config": {
9+
"distDir": "dist",
10+
"buildCommand": "npm run build"
11+
}
12+
}
13+
],
14+
"routes": [
15+
{
16+
"src": "/(.*)",
17+
"dest": "/client/dist/$1"
18+
}
19+
],
20+
"env": {
21+
"VITE_API_URL": "https://syncruncode.onrender.com",
22+
"VITE_SOCKET_URL": "https://syncruncode.onrender.com"
23+
},
24+
"functions": {
25+
"client/dist/**": {
26+
"runtime": "nodejs18.x"
27+
}
28+
}
29+
}

vercel.json

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
{
22
"version": 2,
3-
"buildCommand": "cd client && npm run build",
4-
"outputDirectory": "client/dist",
5-
"installCommand": "cd client && npm install",
6-
"framework": "vite",
3+
"builds": [
4+
{
5+
"src": "client/package.json",
6+
"use": "@vercel/static-build",
7+
"config": {
8+
"distDir": "dist"
9+
}
10+
}
11+
],
12+
"routes": [
13+
{
14+
"src": "/(.*)",
15+
"dest": "/client/dist/$1"
16+
}
17+
],
718
"env": {
819
"VITE_API_URL": "https://syncruncode.onrender.com",
920
"VITE_SOCKET_URL": "https://syncruncode.onrender.com"

0 commit comments

Comments
 (0)