Running Locally
Guide to running MMPS in different modes during development.
Development Mode
The standard way to develop and test locally:
bash
npm run start:devThis uses tsx watch to automatically reload when you make changes.
Run a Specific Bot
By default, all bots run in production mode. In development, run one bot at a time:
bash
LOCAL_ACTIVE_BOT_ID=chatbot npm run start:devAvailable bot IDs: chatbot, coach, langly, magister, wolt, worldly
Watch Mode for TypeScript Only
If you want to compile TypeScript without running the app:
bash
npm run dev:buildDebug Mode
Enable Node.js debugging on port 9229:
bash
npm run start:debugThen connect your debugger:
- VS Code: Press
Ctrl+Shift+D, select Node.js from the dropdown - Chrome DevTools: Open
chrome://inspectand click inspect - WebStorm: Run → Edit Configurations → Node.js
Production Mode
Build and run the production version:
bash
npm run build
npm startThis:
- Compiles TypeScript to
dist/ - Resolves path aliases
- Runs the compiled JavaScript
Code Quality
Before committing, run these checks:
bash
# Format code
npm run format
# Check formatting without changes
npm run format:check
# Lint code
npm run lint
# Auto-fix linting issues
npm run lint:fix
# Run tests
npm test
# Watch tests
npm test:watchTesting Bots Locally
Testing Chatbot Locally
- Create a test Telegram bot with @BotFather
- Add the token to
.env:CHATBOT_TELEGRAM_BOT_TOKEN=... - Run:
LOCAL_ACTIVE_BOT_ID=chatbot npm run start:dev - Open Telegram and find your bot
- Send
/startto begin testing
Testing Multiple Bots
To test multiple bots without running separate instances, comment out bots in main.ts:
typescript
// Temporarily disable in main.ts
// if (shouldInitBot(coachConfig)) await initCoach();Troubleshooting
Port or PID Already in Use
Stop any existing processes:
bash
# Find and kill process on port
lsof -i :3000
kill -9 <PID>Bot Not Responding
- Check
.envfile has correct bot token - Verify MongoDB is running:
mongoshshould connect - Check console logs for errors
- Ensure
LOCAL_ACTIVE_BOT_IDis set correctly
TypeScript Compilation Errors
bash
npm run build # See detailed errors
npm run lint # Check for code style issuesMongoDB Connection Failed
bash
# Verify MongoDB is running
brew services list # macOS
mongo --eval "db.adminCommand('ping')"
# Check MONGO_URI in .env
# For local: mongodb://localhost:27017
# For Atlas: mongodb+srv://username:password@...Best Practices
- Use one bot at a time - Set
LOCAL_ACTIVE_BOT_IDto avoid resource conflicts - Keep debug logs on - They help identify issues quickly
- Test with a test bot - Create dedicated test bots on Telegram
- Use
.env.local- Sensitive credentials in this file (add to .gitignore)