Setting Up the Environment
Let's set up the complete development environment for the course.
Installing Node.js
Download from nodejs.org version LTS (20.x or higher).
bash
# Check installationnode --versionnpm --versionCreating the Project
bash
# Create folder and initializemkdir ecommerce-apicd ecommerce-apinpm init -yInstalling TypeScript
bash
npm install -D typescript ts-node @types/nodenpx tsc --initTypeScript Configuration
json
// tsconfig.json{ "compilerOptions": { "target": "ES2022", "module": "commonjs", "lib": ["ES2022"], "outDir": "./dist", "rootDir": "./src", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true }, "include": ["src/**/*"], "exclude": ["node_modules", "dist"]}Project Structure
ecommerce-api/
├── src/
│ ├── config/
│ ├── controllers/
│ ├── middlewares/
│ ├── routes/
│ ├── services/
│ └── server.ts
├── prisma/
├── tests/
├── package.json
└── tsconfig.json
Useful Scripts
json
// package.json{ "scripts": { "dev": "ts-node src/server.ts", "build": "tsc", "start": "node dist/server.js" }}VS Code Extensions
- ESLint
- Prettier
- Prisma
- Thunder Client (API testing)
Environment Variables
bash
npm install dotenvenv
# .envPORT=3000NODE_ENV=developmentDATABASE_URL="postgresql://user:pass@localhost:5432/ecommerce"Summary
- ✅ Node.js 20+ installed
- ✅ TypeScript configured
- ✅ Project structure organized
- ✅ Scripts ready
Next lesson: First Express Server! 🚀