# JavaScript on the Server with Node.js

> Learn Node.js, its event loop, npm and a web framework like Express or Fastify to build HTTP APIs. Free notes, key concepts, resources and a mini project.

Canonical: https://www.internhack.in/roadmaps/tracks/backend/nodejs
Last updated: 2026-11-28

Learn Node.js, its event loop, npm and a web framework like Express or Fastify to build HTTP APIs.

Beginner · about 40 hours · difficulty 3/5

Learn first: [HTTP in Depth](https://www.internhack.in/roadmaps/tracks/backend/http-protocol)

**Node.js** runs JavaScript outside the browser on the V8 engine. It is our recommended first backend language because you can use one language across frontend and backend, the package ecosystem (npm) is huge and the job market is large. Pair it with **TypeScript** as soon as you are comfortable, since types catch many bugs before runtime.

### How Node works

Node runs your JavaScript on a **single thread** with an **event loop**. I/O (network, disk, database) is non-blocking: you start an operation and continue, and a callback or `await` resumes when it finishes. This makes Node excellent for I/O-heavy APIs, but a CPU-heavy loop (image processing, big JSON parsing) blocks every other request. Offload such work to worker threads or a separate service.

### What to learn

- Modern JavaScript: `async`/`await`, Promises, modules (ESM), destructuring, error handling.
- npm or pnpm, `package.json`, semantic versioning and lockfiles.
- A framework: **Express** (minimal, ubiquitous), **Fastify** (fast, schema-first) or **NestJS** (opinionated, structured).
- Validating input (Zod or similar), middleware, routing, and centralized error handling.

### Pitfalls

- Unhandled promise rejections crashing the process. Always `await` or `catch`.
- Mixing CommonJS and ESM without understanding the difference.

You are ready to move on when you can build a small CRUD API with routing, validation, error handling and environment-based config, and explain why a synchronous loop hurts every user.

## Key concepts

- **Event loop and async I/O**
- **async/await and Promises**
- **npm, package.json and lockfiles**
- **TypeScript**
- **Express**
- **Fastify**
- **NestJS**
- **Input validation with Zod**
- **Worker threads**

## Other options for this step

- [Python for Backend Development](https://www.internhack.in/roadmaps/tracks/backend/python): Use Python with Django, Flask or FastAPI to build readable, productive web services.
- [Go for Backend Services](https://www.internhack.in/roadmaps/tracks/backend/go): Learn Go's simple syntax, goroutines and standard library to build fast, easily deployed services.
- [Java and the Spring Ecosystem](https://www.internhack.in/roadmaps/tracks/backend/java): Build enterprise-grade services with Java, Maven or Gradle and Spring Boot.
- [C# and ASP.NET Core](https://www.internhack.in/roadmaps/tracks/backend/csharp): Build cross-platform web APIs with C#, .NET and ASP.NET Core.
- [PHP and Laravel](https://www.internhack.in/roadmaps/tracks/backend/php): Use modern PHP with Laravel or Symfony, the stack behind a large share of the web.
- [Ruby on Rails](https://www.internhack.in/roadmaps/tracks/backend/ruby): Build products quickly with Ruby and Rails' convention-over-configuration approach.
- [Rust for High-Performance Backends](https://www.internhack.in/roadmaps/tracks/backend/rust): Use Rust with Axum or Actix for memory-safe, very fast services, accepting a steeper learning curve.

## Mini project

Build a TypeScript Express or Fastify API for a bookmarks app with CRUD endpoints, Zod validation, a global error handler and config loaded from environment variables.

## Check yourself

What happens to other in-flight requests when one request handler runs a 3-second synchronous loop in Node.js?

## Free resources

- [Node.js Learn](https://nodejs.org/en/learn) (Node.js)
- [Express documentation](https://expressjs.com/) (Express)
- [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/intro.html) (TypeScript)

Previous: [Collaborating on Hosted Repositories](https://www.internhack.in/roadmaps/tracks/backend/repo-hosting) · Next: [Python for Backend Development](https://www.internhack.in/roadmaps/tracks/backend/python)

## More in Pick One Server Language

- [JavaScript on the Server with Node.js](https://www.internhack.in/roadmaps/tracks/backend/nodejs)
- [Python for Backend Development](https://www.internhack.in/roadmaps/tracks/backend/python)
- [Go for Backend Services](https://www.internhack.in/roadmaps/tracks/backend/go)
- [Java and the Spring Ecosystem](https://www.internhack.in/roadmaps/tracks/backend/java)
- [C# and ASP.NET Core](https://www.internhack.in/roadmaps/tracks/backend/csharp)
- [PHP and Laravel](https://www.internhack.in/roadmaps/tracks/backend/php)
- [Ruby on Rails](https://www.internhack.in/roadmaps/tracks/backend/ruby)
- [Rust for High-Performance Backends](https://www.internhack.in/roadmaps/tracks/backend/rust)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Backend Developer Roadmap](https://www.internhack.in/roadmaps/tracks/backend)
