Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
- Enable corepack for proper Yarn version:
corepack enable - Install dependencies:
yarn install(takes ~1 minute) - Start database services:
docker compose up -d --wait(takes ~1-2 minutes, pulls images on first run)
- Build all packages:
yarn build-- takes 2 minutes. NEVER CANCEL. Set timeout to 180+ seconds. - Lint and type-check:
yarn lint-- takes ~30 seconds. NEVER CANCEL. Set timeout to 120+ seconds. Runs oxlint, type-aware rules, and tsgo type diagnostics via--type-check. - Run all tests:
yarn test-- takes 15+ minutes. NEVER CANCEL. Set timeout to 1800+ seconds. - Run fast tests (excludes schema generator):
yarn test:fast-- takes 10+ minutes. NEVER CANCEL. Set timeout to 1200+ seconds. - Clean test artifacts:
yarn clean-tests
docker compose down --volumes --remove-orphans --rmi local
yarn clean-tests
yarn
docker compose up -d- Build docs:
cd docs && yarn && yarn build-- takes 9+ minutes. NEVER CANCEL. Set timeout to 900+ seconds. - Local docs server:
cd docs && yarn start
- ALWAYS run
yarn buildbefore committing any package changes. - ALWAYS run
yarn lintbefore committing or the CI (.github/workflows/tests.yml) will fail.yarn lintalready covers TypeScript type-checking viaoxlint --type-check. - Test CLI functionality:
node ./packages/cli/dist/cli --help
- MongoDB tests may fail due to network restrictions downloading mongodb-memory-server binaries from fastdl.mongodb.org.
- Network-dependent tests may not work in restricted environments.
- Use
yarn test --testPathPattern="sqlite"to run SQLite-only tests when MongoDB is unavailable. - Docker services are required for full database testing (PostgreSQL, MySQL, MariaDB, MSSQL, MongoDB).
- Test CLI commands:
node ./packages/cli/dist/cli debug,node ./packages/cli/dist/cli --version - Test database connection with Docker services running
- Test entity generation and migration commands in test environments
- 17 packages in
packages/directory:core- Main ORM functionalitycli- Command line interfaceknex- Knex.js query builder integrationmigrations- Migration systementity-generator- Code generationseeder- Database seedingreflection- Metadata reflection- Database drivers:
postgresql,mysql,mariadb,sqlite,better-sqlite,libsql,mssql,mongodb
packages/- All publishable packagestests/- Comprehensive test suite with multiple entity setsdocs/- Docusaurus documentation websitescripts/- Build and utility scripts.github/workflows/- CI/CD pipelines
lerna.json- Monorepo versioning (current: 6.5.5)jest.config.js- Test configurationtsconfig.json- TypeScript configuration for developmenttsconfig.build.json- TypeScript configuration for buildingeslint.config.mjs- Linting rulesdocker-compose.yml- Database services for testing
tests/entities/- Main test entitiestests/entities-sql/- SQL-specific entitiestests/entities-schema/- EntitySchema examplestests/entities-js/- JavaScript entitiestests/entities-mssql/- MSSQL-specific entitiestests/defineEntity.test.ts-defineEntityexamples
The build is orchestrated by Lerna and runs packages in topological order:
- Core packages (mikro-orm, @mikro-orm/core) build first
- Driver packages build in parallel
- CLI and tools build last
- Each package has:
src/(TypeScript),dist/(compiled), individual package.json - Build single package:
cd packages/[name] && yarn build - Package scripts:
yarn clean,yarn compile,yarn copy
- Unit tests for individual packages
- Integration tests with real databases
- CLI command tests
- Schema generator tests (slow - excluded from yarn test:fast)
- Cross-database compatibility tests
# Debug configuration
node ./packages/cli/dist/cli debug
# Generate entities
node ./packages/cli/dist/cli generate-entities
# Run migrations
node ./packages/cli/dist/cli migration:up
# Schema operations
node ./packages/cli/dist/cli schema:update --run- Build job: TypeScript check, build all packages
- Lint job: ESLint validation
- Test job: Matrix testing on Node.js 18, 20, 22, 24 with all databases
- Docs job: Documentation build and spell check
- Publish job: Development releases to npm
- Node.js versions: 18.12.0+
- Yarn version: 4.10.0 (managed by corepack)
- TypeScript: 5.9.2
- Jest for testing with custom runtime
- MongoDB memory server fails: Network restrictions prevent binary download
- Docker services not starting: Check Docker daemon and port conflicts
- Build failures after git pull: Run environment reset commands
- TypeScript errors in tests: Run
yarn lintto validate (includes tsgo type diagnostics) - Linting failures: Run
yarn lintbefore committing
- Use
--max-workersflag for Jest to control parallelism - Documentation builds are resource-intensive (9+ minutes)
- Full test suite can take 15+ minutes with all databases
- Fork and clone repository
- Run complete environment setup
- Make focused changes to specific packages
- Run validation steps before committing
- Submit PR with all checks passing
Remember: This is a production TypeScript ORM used by thousands of projects. Always validate thoroughly and follow the existing patterns and conventions in the codebase.