01
🇺🇦 Українська
У цьому уроці ми налаштуємо повноцінне середовище для backend-розробки на Windows. Node.js — це середовище виконання JavaScript поза браузером. TypeScript додає статичну типізацію, що робить код надійнішим. Ми встановимо всі необхідні інструменти і створимо перший TypeScript-проєкт з правильною структурою.
🇬🇧 English
In this lesson we set up a full backend development environment on Windows. Node.js is a JavaScript runtime outside the browser. TypeScript adds static typing that makes code more reliable. We'll install all necessary tools and create the first TypeScript project with a proper structure.
Installation Steps
- 1Download Node.js LTS from nodejs.org — choose the Windows Installer (.msi). After install, run:
node -v - 2Install TypeScript globally:
npm install -g typescript ts-node nodemon - 3Create project folder and init npm + TypeScript config
- 4Install dev dependencies for testing and building
Project Initialization
Windows PowerShell / CMD
PS> mkdir my-backend && cd my-backend PS> npm init -y PS> npm install -D typescript @types/node ts-node nodemon jest @types/jest ts-jest PS> npx tsc --init
tsconfig.json
tsconfig.json
JSON
{
"compilerOptions": {
"target": "ES2022",
"module": "commonjs",
"lib": ["ES2022"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"declaration": true,
"sourceMap": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts"]
}
package.json Scripts
package.json (scripts section)
JSON
"scripts": { "dev": "nodemon --exec ts-node src/index.ts", "build": "tsc", "start": "node dist/index.js", "test": "jest --coverage", "test:watch": "jest --watch" }
First TypeScript File
src/index.ts
TypeScript
// Entry point of the backend application const greet = (name: string): string => { return `Hello, ${name}! Backend is running.`; }; console.log(greet('World')); console.log(`Node.js version: ${process.version}`);
Test File
✓ Jest Test — src/index.test.ts
import { greet } from './utils/greet'; describe('greet()', () => { it('should return greeting string', () => { const result = greet('Alice'); expect(result).toBe('Hello, Alice! Backend is running.'); }); it('should handle empty string', () => { const result = greet(''); expect(result).toContain('Hello'); }); });
npm run test
PASS src/index.test.ts greet() ✓ should return greeting string (3ms) ✓ should handle empty string (1ms) Test Suites: 1 passed, 1 total Tests: 2 passed, 2 total