Back to course

What is Node.js?

Node.js allows you to run JavaScript outside the browser.

It is built on the V8 engine and uses an event-driven, non-blocking model, which makes it efficient for servers and APIs.

Node.js is not a framework.
It is a runtime.

Running JavaScript with Node

Create a file called index.js:

console.log("Hello from Node.js");

Run it in your terminal:

node index.js

If everything is set up correctly, you should see your message printed.

How Node.js Works (Simple Mental Model)

Node runs JavaScript on a single main thread.

Instead of waiting for slow operations (like reading files or making network requests), Node:

  • starts the task
  • continues executing other code
  • handles the result when it’s ready

This is what makes Node fast and scalable.

Creating a Node Project

Initialize a new project:

npm init -y

This creates a package.json file.

Important things inside:

  • scripts → shortcuts for commands
  • dependencies → installed packages

Quick Exercise

  • Install Node.js
  • Create a new project folder
  • Run a JavaScript file using Node