Prerequisites:
- Node.js v20.19.0+ or ^22.12.0 or >= 23.0.0
- MongoDB database
- npm 11.10.0 (specified as package manager)
Initial Setup
LibreChat uses a monorepo structure with npm workspaces. Follow these steps to set up your development environment.Install dependencies
Use the smart reinstall command that only reinstalls if the lockfile has changed:This command will:
- Check if
package-lock.jsonhas changed - Install dependencies across all workspaces
- Build packages via Turborepo with parallel execution and caching
Alternative installation methods
Alternative installation methods
Clean install (wipes Docker environment:Using Bun (alternative runtime):
node_modules and reinstalls from scratch):Configure environment variables
Copy the example environment file and configure it for your local setup:Update the following required variables in
.env:The backend runs on
http://localhost:3080/ by default.
The frontend dev server runs on http://localhost:3090/.Running the Development Servers
Backend Development Server
Start the backend server with file watching and hot reload:Other backend options
Other backend options
Production mode:With Node.js inspector (for debugging):Experimental features:Stop backend server:Using Bun:
Frontend Development Server
Start the frontend dev server with Hot Module Replacement (HMR):http://localhost:3090/ and will proxy API requests to the backend at http://localhost:3080/.
Using Bun for frontend
Using Bun for frontend
Development Workflow
Making Changes to Data Provider
Thepackages/data-provider package is shared between frontend and backend. After making changes, rebuild it:
Frontend and backend shared API logic (endpoints, types, data-service) goes in
packages/data-provider.Code Formatting and Linting
Testing
Running Tests
LibreChat uses Jest for testing. Tests are run per-workspace:Running Tests in a Workspace
Navigate to the workspace directory and run Jest:Frontend tests are located in
__tests__ directories alongside components. Use test/layout-test-utils for rendering utilities.End-to-End Testing
LibreChat uses Playwright for E2E testing:Node.js Memory Configuration
For large builds or development work, you may need to increase Node.js memory:NODE_MAX_OLD_SPACE_SIZE is used as a Docker build argument but is NOT recognized by Node.js at runtime. Use NODE_OPTIONS instead.Common Issues
Port already in use
Port already in use
If port 3080 or 3090 is already in use:
- Stop any running LibreChat processes
- Kill the process using the port:
- Or change the port in your
.envfile
MongoDB connection failed
MongoDB connection failed
Ensure MongoDB is running:
Build fails with memory errors
Build fails with memory errors
Increase Node.js memory allocation:
Changes not reflecting in data-provider
Changes not reflecting in data-provider
After modifying Then restart both frontend and backend servers.
packages/data-provider, rebuild it:Next Steps
Architecture Overview
Learn about LibreChat’s system architecture and how components interact
Monorepo Structure
Understand the workspace organization and dependencies
Code Style Guide
Follow LibreChat’s coding standards and best practices
Contributing Guide
Learn how to contribute to LibreChat