Skip to contentPedro Farbo
Lesson 2 / 2545 min

Setting Up the Environment

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 --version

Creating the Project

bash
# Create folder and initializemkdir ecommerce-apicd ecommerce-apinpm init -y

Installing TypeScript

bash
npm install -D typescript ts-node @types/nodenpx tsc --init

TypeScript 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 dotenv
env
# .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! 🚀

Enjoyed the content? Your contribution helps keep everything online and free!

PIX:0737160d-e98f-4a65-8392-5dba70e7ff3e