Skip to main content

Introduction to Node.js

Node.js is an open-source, cross-platform runtime environment that allows developers to execute JavaScript code outside of a web browser. It was created by Ryan Dahl in 2009.

The V8 Engine

Prior to Node.js, JavaScript was strictly confined to running within the DOM of a browser (like Chrome or Firefox).

Node.js takes the V8 Engine—the exact same high-performance JavaScript engine that powers Google Chrome—and binds it with a C++ library called libuv. This combination allows JavaScript to interact directly with the operating system, enabling it to read files, open network connections, and act as a standalone backend server.

Why Node.js?

  • Asynchronous & Event-Driven: Node.js operates on a single thread. Instead of waiting for a slow physical database query to finish, Node.js delegates the query to the background and immediately moves on to handle the next web request. This makes it highly scalable for I/O-heavy applications (like Chat Apps or REST APIs).
  • Single Language: Full-stack developers can write both the React frontend and the Node backend using exclusively JavaScript or TypeScript, drastically reducing the mental overhead of switching between completely different languages (like Java or Python).

Executing Code

To run a JavaScript file locally, you simple use the node terminal command.

// app.js
console.log("Hello from the Node console!");
# Terminal execution
node app.js