Learn Node.js by doing. Work through the lessons in order to go from running your first file to building APIs, talking to databases, testing, streams, threads, and shipping to production.
Before you start
Install Node.js (the LTS version) and VS Code. Create a folder, add a file ending in .js (for example app.js), and run it from your terminal with node app.js. This course assumes you already know basic JavaScript.
Running Node.js Code
Run JavaScript outside the browser. Execute a file with the node command, experiment in the REPL, auto-restart on changes with --watch, and run one-off tools with npx.
Modules
Split your code across files. Learn CommonJS (require/module.exports) and modern ES Modules (import/export), how to pick one, and the global objects available everywhere.
npm & Packages
Use npm to manage your project. Create a package.json, install and update packages, separate dependencies from devDependencies, run scripts, read version ranges, and use workspaces.
Asynchronous Programming
Handle work that takes time without freezing your app. Master callbacks, Promises, async/await, the timer functions, and the EventEmitter pattern.
Error Handling
Stop crashes and respond to failure gracefully. Learn try/catch, handling errors in async code and callbacks, custom error classes, and last-resort process handlers.
Working with the File System
Read, write, and manage files. Use fs/promises, build safe paths with the path module, understand __dirname vs cwd, and reach for fs-extra, globby, and chokidar.
Environment Variables
Keep secrets and settings out of your code. Read configuration from process.env and load it from a .env file with dotenv.
Consuming APIs
Call other servers from Node. Use the built-in fetch to GET and POST data, handle JSON responses and errors, and reach for axios when you want extra conveniences.
Authentication
Identify your API users. Hash passwords, issue and verify JSON Web Tokens (JWT), protect routes with middleware, and understand where Passport.js fits.
Databases & ORM (Prisma)
Store data permanently in PostgreSQL through an ORM. Set up Prisma, define a model, run a migration, do full CRUD, and connect tables with relations — reading related rows back as nested objects instead of writing JOINs by hand.
Testing
Prove your code works and keep it working. Write tests with the built-in node:test runner and assert module, then with Vitest, and learn where Jest, Cypress, and Playwright fit.
Logging & Running in Production
Get ready for production. Replace console.log with structured logging via Winston, log HTTP requests with Morgan, and keep your app alive and restarting with pm2.
Building for Scale: Observability & Resilience
Keep a busy service healthy. Measure it with metrics (prom-client), watch it with Prometheus, trace requests with OpenTelemetry, and survive failure with graceful degradation, rate limiting, and a circuit breaker.
Real-Time Data with WebSockets
Push live updates to the browser. Learn why WebSockets exist, build a server with the ws library, broadcast to every connected client, connect from the browser, and know when to reach for Socket.IO.