docs/FrontendBuildGuide.md
The LightRAG project includes a React-based WebUI frontend. This guide explains how frontend building works in different scenarios.
Command:
pip install lightrag-hku[api]
What happens:
Command:
# Clone the repository
git clone https://github.com/HKUDS/LightRAG.git
cd LightRAG
# Install in editable mode (no frontend build required yet)
pip install -e ".[api]"
# Build frontend when needed (can be done anytime)
cd lightrag_webui
bun install --frozen-lockfile
bun run build
cd ..
Advantages:
How it works:
lightrag/api/webui/Command:
# Clone the repository
git clone https://github.com/HKUDS/LightRAG.git
cd LightRAG
# ⚠️ MUST build frontend FIRST
cd lightrag_webui
bun install --frozen-lockfile
bun run build
cd ..
# Now install
pip install ".[api]"
What happens:
When to use:
Command:
# Build frontend first
cd lightrag_webui
bun install --frozen-lockfile --production
bun run build
cd ..
# Create distribution packages
python -m build
# Output: dist/lightrag_hku-*.whl and dist/lightrag_hku-*.tar.gz
What happens:
setup.py checks if frontend is builtWhen creating a release on GitHub:
No manual intervention required!
| Scenario | Command | Frontend Required | Can Build After |
|---|---|---|---|
| From PyPI | pip install lightrag-hku[api] | Included | No (already installed) |
| Development | pip install -e ".[api]" | No | ✅ Yes (anytime) |
| Normal Install | pip install ".[api]" | ✅ Yes (before) | No (must reinstall) |
| Create Package | python -m build | ✅ Yes (before) | N/A |
If you don't have Bun installed:
# macOS/Linux
curl -fsSL https://bun.sh/install | bash
# Windows
powershell -c "irm bun.sh/install.ps1 | iex"
Official documentation: https://bun.sh
LightRAG/
├── lightrag_webui/ # Frontend source code
│ ├── src/ # React components
│ ├── package.json # Dependencies
│ └── vite.config.ts # Build configuration
│ └── outDir: ../lightrag/api/webui # Build output
│
├── lightrag/
│ └── api/
│ └── webui/ # Frontend build output (gitignored)
│ ├── index.html # Built files (after running bun run build)
│ └── assets/ # Built assets
│
├── setup.py # Build checks
├── pyproject.toml # Package configuration
└── .gitignore # Excludes lightrag/api/webui/* (except .gitkeep)
A: Build the frontend:
cd lightrag_webui && bun run build
A: You probably used pip install . after building. Either:
pip install -e ".[api]" for developmentpip uninstall lightrag-hku && pip install ".[api]"A: In lightrag/api/webui/ after running bun run build
A: Yes. The build scripts (dev, build, preview, lint) are runtime-agnostic and work with both Bun and Node.js/npm:
npm install
npm run build
Bun is recommended for speed, but npm is fully supported. Tests (bun test) still require Bun.
Cannot find package '@/lib'A: This was caused by vite.config.ts using a TypeScript path alias (@/) that only Bun could resolve at config load time. Update to the latest version where this is fixed with a relative import.
✅ PyPI users: No action needed, frontend included
✅ Developers: Use pip install -e ".[api]", build frontend when needed
✅ CI/CD: Automatic build in GitHub Actions
✅ Git: Frontend build output never committed
For questions or issues, please open a GitHub issue.