69 lines
1.5 KiB
Markdown
69 lines
1.5 KiB
Markdown
|
|
# Vite Configuration Fix - Node.js Built-ins Error ✅
|
||
|
|
|
||
|
|
**Issue**: `Failed to resolve entry for package "https"` - Vite trying to bundle Node.js built-ins
|
||
|
|
|
||
|
|
**Root Cause**: Some dependencies are trying to use Node.js modules (https, http, etc.) in browser context
|
||
|
|
|
||
|
|
**Solution**: Configure Vite to exclude Node.js built-ins from optimization
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## ✅ Fix Applied
|
||
|
|
|
||
|
|
### Updated `vite.config.ts`
|
||
|
|
|
||
|
|
Added configuration to exclude Node.js built-in modules:
|
||
|
|
|
||
|
|
```typescript
|
||
|
|
optimizeDeps: {
|
||
|
|
exclude: ['https', 'http', 'url', 'stream', 'util', 'crypto', 'buffer', 'events', 'path', 'fs', 'os', 'net', 'tls', 'zlib'],
|
||
|
|
},
|
||
|
|
define: {
|
||
|
|
global: 'globalThis',
|
||
|
|
},
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 🔄 What This Does
|
||
|
|
|
||
|
|
1. **optimizeDeps.exclude**: Tells Vite not to try to bundle Node.js built-in modules
|
||
|
|
2. **define.global**: Provides globalThis for browser compatibility
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 🚀 Server Status
|
||
|
|
|
||
|
|
- ✅ Vite config updated
|
||
|
|
- ✅ Cache cleared
|
||
|
|
- ✅ Server restarted
|
||
|
|
- ✅ Dependencies optimizing
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 📝 If Issues Persist
|
||
|
|
|
||
|
|
### Option 1: Check Browser Console
|
||
|
|
Open browser DevTools (F12) and check for any remaining errors
|
||
|
|
|
||
|
|
### Option 2: Hard Refresh
|
||
|
|
- Chrome/Edge: Ctrl+Shift+R or Cmd+Shift+R
|
||
|
|
- Firefox: Ctrl+F5 or Cmd+Shift+R
|
||
|
|
|
||
|
|
### Option 3: Clear Browser Cache
|
||
|
|
Clear browser cache and reload the page
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## ✅ Expected Result
|
||
|
|
|
||
|
|
After this fix:
|
||
|
|
- ✅ No more "Failed to resolve entry for package" errors
|
||
|
|
- ✅ Server starts successfully
|
||
|
|
- ✅ Application loads in browser
|
||
|
|
- ✅ All dependencies work correctly
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
**✅ Configuration Fixed - Server Ready!**
|