Development Environment Setup
Prerequisites​
Required Software​
-
Node.js
- Version: v22.12.0
- Installation: Node.js website
-
pnpm
- Version: v10.0.0
- Installation:
curl -fsSL https://get.pnpm.io/install.sh | sh - - Verify installation:
pnpm --version
-
Git
- Latest version
- Installation: Git website
-
IDE/Editor
- VSCode (recommended)
- Required extensions:
- ESLint
- Prettier
- GitLens
- Docker
-
Docker
- Latest version
- Installation: Docker website
Environment Setup​
1. Repository Setup​
# Clone repository
git clone <repository-url>
cd <repository-name>
# Install dependencies
pnpm install
# Setup git hooks
pnpm prepare
2. Environment Variables​
# Copy environment template
cp .env.example .env
# Edit environment variables
nano .env
Required variables:
NODE_ENV=development
API_URL=http://localhost:3000
DATABASE_URL=postgresql://user:password@localhost:5432/dbname
3. Database Setup​
# Start database container
docker-compose up -d db
# Run migrations
pnpm db:migrate
# Seed initial data
pnpm db:seed
4. Local Services​
# Start all services
docker-compose up -d
# Start specific service
docker-compose up -d service-name
# View logs
docker-compose logs -f [service-name]
Development Workflow​
1. Starting Development​
# Start development server
pnpm dev
# Start with debugger
pnpm dev:debug
2. Running Tests​
# Run all tests
pnpm test
# Run specific test file
pnpm test path/to/test
# Run tests in watch mode
pnpm test:watch
3. Code Quality​
# Lint code
pnpm lint
# Fix linting issues
pnpm lint:fix
# Format code
pnpm format
IDE Configuration​
VSCode Settings​
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"typescript.tsdk": "node_modules/typescript/lib"
}
ESLint Configuration​
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
root: true
};
Prettier Configuration​
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5"
}
Debugging​
1. VSCode Launch Configuration​
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Server",
"program": "${workspaceFolder}/src/index.ts",
"preLaunchTask": "tsc: build",
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"env": {
"NODE_ENV": "development"
}
}
]
}
2. Chrome DevTools​
- Start server with
--inspectflag - Open Chrome DevTools
- Click Node.js icon
- Set breakpoints
3. Debug Logs​
// Development only logs
if (process.env.NODE_ENV === 'development') {
console.log('Debug:', data);
}
// Production safe logs
logger.debug('Operation:', {
action: 'create',
resource: 'user',
data: sanitizeData(data)
});
Common Issues​
1. Port Conflicts​
# Find process using port
lsof -i :3000
# Kill process
kill -9 <PID>
2. Dependencies Issues​
# Clear dependency cache
pnpm store prune
# Reinstall dependencies
rm -rf node_modules
pnpm install
3. Docker Issues​
# Remove containers
docker-compose down
# Remove volumes
docker-compose down -v
# Rebuild images
docker-compose build --no-cache
Best Practices​
1. Git Workflow​
- Keep branches up to date
- Write meaningful commit messages
- Regular small commits
- Create feature branches
- Review before push
2. Code Style​
- Follow ESLint rules
- Use TypeScript strictly
- Document complex logic
- Write unit tests
- Keep functions small
3. Performance​
- Use development builds
- Enable source maps
- Profile when needed
- Monitor memory usage
- Use debugging tools
Support​
Internal Resources​
- Documentation wiki
- Team chat channels
- Issue tracker
- Knowledge base
External Resources​
- Stack Overflow
- GitHub issues
- Documentation
- Community forums