Node.js

A runtime for running JavaScript outside the browser, on servers and in tools.

Node.js runs JavaScript outside the browser using Chrome's V8 engine. It handles many network and file operations at once without blocking, which suits web servers, APIs and command-line tools, and it lets you use one language for both frontend and backend.

  • Intermediate
  • 7 lessons
  • Runs in your browser
Not started yet
Start lesson 1

Lessons

  1. Hello, Node.js!Run your first Node.js script and read command-line arguments and environment variables. Node has no `window` or `document`, but it can use the file system, the network and packages from npm.
  2. File SystemLearn to read, write and list files with Node's `fs` module. The examples use the promises API (`fs/promises`), which works with async/await instead of callbacks.
  3. HTTP ServerBuild a web server with Node's built-in http module, then the same kind of server with Express. Seeing the plain version first makes it clearer what Express does for you.
  4. Modules & npmLearn to split code across files with modules and to install packages with npm. package.json describes your project, its scripts and its dependencies.
  5. Async PatternsLearn the common patterns for asynchronous code in Node: promises, async/await, running tasks in parallel, timeouts and retries. They keep your program responsive while it waits on files and networks.
  6. Mini Project: REST API with PersistenceBuild a small REST API for notes that saves data to a JSON file, using Express and the file system. No database setup is needed.
  7. Node.js CheatsheetRuntime APIs, modules, files, and servers on one page.

Install it on your own computer

Install Node.js with nvm (Node Version Manager), which also lets you switch between Node versions later. You do not need this to follow the lessons: the examples run in your browser.

Bash
# Install nvm-windows from github.com/coreybutler/nvm-windows
# Then:
nvm install lts
nvm use lts

# Verify:
node --version
npm --version

What people build with Node.js

Learn the basics first, then pick up these tools when a project needs them.

Practical uses

  • Serve APIs and realtime applications
  • Build command-line developer tools
  • Process queues, uploads, and webhooks
  • Run JavaScript automation and build systems

Projects to try

  1. File-renaming CLI
  2. Webhook inspector
  3. WebSocket chat server
  4. Background job processing service

Common tools and packages

ExpressFastifyNestJSPrismaSocket.IOBullMQPinoCommander.js

Well-known software

npmGhostStrapiDirectusWebpackPrettier