Prerequisites
Required Software
- macOS
- Linux
- Windows
Version Requirements
| Tool | Version |
|---|---|
| Node.js | 22.x (LTS) |
| Yarn | 4.x |
| Rust | 1.70+ |
| Git | 2.30+ |
Clone the Repository
Fork the repository
Visit github.com/toeverything/AFFiNE and click Fork
Install Dependencies
Install Node.js dependencies
Start Development Server
Web App
Start the web application:- Web app on http://localhost:8080
- Vite dev server with HMR
Desktop App
Start the Electron desktop app:- Electron app window
- Dev server on http://localhost:8080
- Auto-reload on changes
Backend Server
For full-stack development:Start server
Project Structure
Understanding the codebase:Development Workflow
Creating a Feature
Commit Convention
Follow Conventional Commits:Common Commands
Build Commands
Linting & Formatting
Testing
Type Checking
Troubleshooting
Build Errors
Native module build fails
Native module build fails
Make sure you have:
- Rust installed:
rustc --version - C++ compiler:
gcc --versionor Visual Studio Build Tools - Python 3:
python --version
Out of memory errors
Out of memory errors
Increase Node.js memory:
Port already in use
Port already in use
Kill the process on port 8080:
Dev Server Issues
Changes not reflecting
Changes not reflecting
- Clear Vite cache:
rm -rf node_modules/.vite - Restart dev server
- Hard refresh browser (Ctrl/Cmd + Shift + R)
WebSocket connection fails
WebSocket connection fails
Check that:
- Backend server is running
- Correct ports configured
- No CORS issues
- WebSocket not blocked by firewall
IDE Setup
VS Code
Recommended extensions:- ESLint
- Prettier
- TypeScript and JavaScript Language Features
- Rust Analyzer
- GraphQL
.vscode/settings.json):
WebStorm
- Enable ESLint: Settings → Languages & Frameworks → JavaScript → Code Quality Tools → ESLint
- Enable Prettier: Settings → Languages & Frameworks → JavaScript → Prettier
- Set Node.js version: Settings → Languages & Frameworks → Node.js