TExcelTAD
Home › Node.js › Node.js Intro

Node.js Introduction

Node.js is a JavaScript runtime: a program that runs JavaScript outside of a web browser. It takes Google's V8 engine (the same one inside Chrome), adds a large standard library for files, networking, processes and more, and wraps it all in an event loop that lets one thread juggle thousands of connections at once.

With Node.js, the language you already use for web pages can also power servers, command-line tools, build systems and desktop apps.

What is Node.js used for?

  • Web servers and APIs — REST and GraphQL back ends, real-time chat, streaming
  • Command-line tools — npm, eslint, prettier and Vite are all Node programs
  • Build tooling — bundlers, compilers and test runners for front-end projects
  • Scripts and automation — renaming files, processing CSV/JSON, calling APIs
  • Desktop apps — Electron apps such as VS Code are built on Node

Why learn Node.js?

Feature What it means for you
One language everywhere Share code and skills between the browser and the server
Non-blocking I/O A single process can serve many clients without waiting on the disk or network
Huge ecosystem npm hosts millions of open-source packages
Fast startup Great for small scripts and serverless functions
Batteries included fs, http, crypto, test and more ship with Node itself

Your first Node.js program

A Node program is just a .js file. Everything you know about JavaScript still works, and console.log writes to the terminal (standard output) instead of the browser's dev tools.

node · try it yourself
const name = "Node.js";
console.log(`Hello from ${name}!`);
console.log("2 + 3 =", 2 + 3);
Hello from Node.js!
2 + 3 = 5

Note: Node.js APIs such as files and servers cannot run inside a web page, so on this site node playgrounds are simulated: you see the saved output. Every example was run with real Node.js (v24) to produce that output, so it is exactly what you will get on your own machine.

Something the browser can't do

Here is a taste of what makes Node different. The program below asks Node which version it is running and lists a few of its built-in modules — things a browser page has no access to.

node · try it yourself
const { builtinModules } = require("node:module");

const major = Number(process.versions.node.split(".")[0]);
console.log("Running on Node 22 or newer:", major >= 22);
console.log("Has fs module:", builtinModules.includes("fs"));
console.log("Has http module:", builtinModules.includes("http"));
console.log("Has DOM document:", typeof document !== "undefined");
Running on Node 22 or newer: true
Has fs module: true
Has http module: true
Has DOM document: false

process is a global object that describes the running program, and require loads a module. There is no document or window: Node has no web page to draw.

How Node.js works, in one picture

  1. You start a script with node app.js.
  2. V8 compiles and runs your code from top to bottom.
  3. Slow operations (reading a file, waiting for a network reply) are handed off to the operating system.
  4. When one finishes, its callback or promise is queued, and the event loop runs it as soon as the main thread is free.
  5. When there is nothing left to wait for, the process exits.
node · try it yourself
console.log("1. start");

setTimeout(() => {
  console.log("3. timer fired");
}, 0);

console.log("2. end of script");
1. start
2. end of script
3. timer fired

Even a 0 ms timer runs after the current script finishes. That ordering is the heart of Node's event loop, and you'll study it in detail later in this course.

What you will learn

This course follows a path from the basics to real applications:

Section Topics
Node.js Tutorial modules, npm, events, files, paths, HTTP, streams, buffers, async code, crypto, processes
Node.js Web building HTTP servers, routing, JSON APIs, Express, middleware, fetch, config, databases
Node.js Tooling testing, debugging, TypeScript and deployment
Practice exercises and a mini project

Tip: You only need basic JavaScript (variables, functions, objects, arrays) to start. The "JavaScript Requirements" lesson reviews the modern features Node code uses most.

Test yourself

Which JavaScript engine does Node.js use?

  1. SpiderMonkey
  2. V8
  3. JavaScriptCore
  4. Chakra

Which of these is NOT available as a global in Node.js?

  1. console
  2. process
  3. document
  4. setTimeout

In what order do these lines print? setTimeout(() => log('A'), 0); log('B');

  1. A then B
  2. B then A
  3. Only B
  4. It depends on the CPU