What is Node? Complete Guide to Node.js
What is Node.js
Node.js is a runtime environment that lets us run JavaScript code on your computer, server, or the cloud. It enables developers to use JavaScript for building interactive web pages and handle server-side tasks like reading files, serving websites, or creating APIs.
Node.js uses Chrome’s V8 engine to execute JavaScript. But unlike a browser, Node doesn’t come with a DOM or window object. Instead, it has modules that let you work with the file system, handle HTTP requests, stream data, and more. In short, Node brings JavaScript to the backend.
Let’s understand why developers choose it in the first place.
Why use Node.js
Node.js has become one of the most popular choices for building fast, scalable web applications, and here’s why:
With Node.js, JavaScript can be used on the frontend and the backend, simplifying development, reducing context-switching, and making it easy to share code between client and server.
Node’s core strength is its asynchronous, event-driven architecture. It doesn’t wait around for file reads or database calls to finish. Instead, it keeps going, handling other tasks in the meantime.
Node.js runs on Google’s V8 engine, which compiles JavaScript into machine code for speed, making server-side code run really fast.
Node.js comes with access to
npm(Node Package Manager), the world’s largest ecosystem of open-source libraries.Because Node handles many operations concurrently without spawning new threads, it uses less memory and scales well under load.
So how does Node.js actually work behind the scenes to handle so many tasks efficiently?
Node.js architecture
The Node.js architecture is designed to handle multiple client requests without creating new threads for each one. Instead, it uses a single-threaded event loop paired with asynchronous, non-blocking operations.

Here’s the flow:
Incoming requests to event queue: When users make requests like reading a file, querying a database, etc., these requests are pushed into the event queue.
Event loop checks the queue: The event loop continuously monitors the event queue. It picks up tasks one at a time and decides how to handle them.
If the task is non-blocking (like reading a file or making an HTTP call), the event loop delegates it to non-blocking I/O operations.
If the task is blocking (like encryption, compression, or CPU-heavy tasks), it is offloaded to a thread pool using libuv, a C++ library under Node.js.
Non-blocking operations: Tasks that involve I/O polling (like network access or disk reads) don’t block the thread. Node offloads them to the system, and once they complete, a callback is pushed back to the event queue for the event loop to handle.
Blocking operations via thread pool: More resource-heavy tasks go through a thread pool, where they are processed without freezing the main thread. Once done, their results are also sent back to the event loop via callbacks.
Final callback: Once an operation is completed, the result is placed back in the event queue, and the event loop eventually executes the corresponding callback.
This architecture is what makes Node.js extremely efficient for applications with high I/O demands, like real-time chat apps, streaming platforms, and APIs.
Before we explore built-in modules, let’s first look at how to install Node.js and run it on your system.
How to install Node.js
To install Node.js on your system, visit the official Node.js website. You’ll see two versions:
LTS (Long-Term Support): Stable and recommended for most users.
Current: Latest features, but may change more frequently.
Download and install the version that suits you. The installer includes both Node.js and npm, which you’ll use to manage packages. After installation, open your terminal and run the following commands:
node -vnpm -v
This checks if Node and npm were installed correctly. With Node.js installed, it’s time to write your first script and see it in action.
Writing the first Node.js script
Node.js isn’t tied to the browser, so you’re not dealing with window, alert, or the DOM. Instead, you write code that interacts with the system. Open VS Code and create a new file main.js and paste this code:
const name = process.argv[2] || "stranger";const time = new Date().toLocaleTimeString();console.log(`Hello, ${name}! The current time is ${time}.`);
In this code:
process.argv[2]grabs the value you pass when running the script—like a name.- If no name is given, it defaults to
"stranger". new Date().toLocaleTimeString()gets the current time.console.log()prints a personalized message.
Now, to run this script, in the terminal, use the following command:
node main.js Alice
The output of this code is:
Hello, Alice! The current time is 1:19:03 pm.
Or, if you just run:
node main.js
The output will be:
Hello, stranger! The current time is 1:21:27 pm.
This is what Node.js does well: lightweight scripts, CLI tools, or services that can scale into much more powerful applications.
Using Node as a REPL
Node can also be used as a Read-Evaluate-Print-Loop, or REPL in a terminal window. This functionality allows you to execute JavaScript commands from the command line.
With Node installed, you can launch the REPL by running the node command in a terminal and pressing Enter as follows:
Node
You are now in an interactive JavaScript environment and can run any valid JavaScript code. Here’s an example code on the REPL:
Welcome to Node.js v22.14.0.Type ".help" for more information.> 2 + 24> const greet = name => `Hello, ${name}!`;undefined> greet('Mamta')'Hello, Mamta!'
To exit the REPL, press Ctrl + C twice or type .exit.
Applications of Node.js
Node.js is used across industries to build fast, scalable, and real-time applications. Here are some common use cases:
**Web Servers and APIs **: Build RESTful APIs or full web servers with frameworks like Express.
Real-Time Apps: Ideal for chat apps, online games, and live collaboration tools that need instant updates.
Streaming Services: Handle audio/video streaming using Node’s native support for data streams.
Microservices Architecture: Lightweight and modular, perfect for breaking large systems into smaller, independent services.
Command-Line Tools: Build powerful CLI apps that interact with the file system or automate workflows.
Serverless Functions: Easily deploy functions to cloud platforms like AWS Lambda or Vercel.
IoT and Hardware Control: Communicate with sensors, devices, and microcontrollers using packages like johnny-five.
Single Page Applications (SPAs): Serve frontend code and handle dynamic routing for apps built with React, Vue, or Angular.
Conclusion
In this article, we broke down what Node.js is, explored its architecture, walked through how to install it, ran your first script, and looked at how the REPL works. We also saw where Node.js fits into real-world applications—like building servers, APIs, and full-stack tools.
If you’re looking to go hands-on and level up your skills, head over to Codecademy’s Learn Node.js course.
Frequently asked questions
1. Is NodeJS backend or frontend?
Node.js is primarily used for backend development. It allows you to run JavaScript on the server to handle APIs, databases, and business logic.
2. Is NodeJS a language?
No, Node.js is not a programming language. It’s a runtime environment that lets you run JavaScript code outside a web browser.
3. What is NodeJS vs React?
Node.js runs JavaScript on the server side, while React is a JavaScript library for building user interfaces on the client side. In short, Node = backend, React = frontend.
4. Is Node a coding language?
No. “Node” (short for Node.js) is not a coding language. It uses JavaScript, which is a language. Node just provides the environment to execute it outside the browser.
5. What is NodeJS mostly used for?
Node.js is mostly used to build fast and scalable network applications, like APIs, web servers, real-time chat apps, and tools like task runners or CLIs.
'The Codecademy Team, composed of experienced educators and tech experts, is dedicated to making tech skills accessible to all. We empower learners worldwide with expert-reviewed content that develops and enhances the technical skills needed to advance and succeed in their careers.'
Meet the full teamRelated articles
- Article
Setting Up Node Locally
Learn how to download Node on your local machine, so you can use the powerful Node.js runtime from your own computer. - Article
Getting started with Node Package Manager
Learn how to use Node Package Manager (NPM) to install, manage, and update dependencies in Node.js projects with best practices and examples. - Article
Express.js Explained: What it is and How to Use it in Your JavaScript Project
Discover what Express.js is, how it works with Node.js, and how to use it in your JavaScript projects. Learn about its features, advantages, and practical examples.
Learn more on Codecademy
- Get an introduction to Node.js—a JavaScript runtime environment typically used to build back-end apps.
- Beginner Friendly.3 hours
- Learn about the different components of a web application's back-end and explore the Node.js JavaScript runtime environment.
- Intermediate.5 hours
- Build an HTTP server using Node.js to facilitate the connection between a client and a server.
- Beginner Friendly.2 hours