JavaScript

Intro to Node.js & Runtime

Start your backend journey! Learn what Node.js is, how it works, and why it changed web development forever.

By TechCoder TeamLast updated: 2026-06-02
In a Nutshell

Start your backend journey! Learn what Node.js is, how it works, and why it changed web development forever. This hands-on tutorial focuses on practical implementation of intro to node.js & runtime concepts.

Intro to Node.js & Runtime

Welcome to the Backend! πŸš€

For a long time, JavaScript only lived in the browser. It handled clicks and animations. If you wanted to build a server (to save data, handle logins), you had to learn PHP, Python, or Java.

Node.js changed everything. It took JavaScript out of the browser and let it run on your computer (server).

1. What is Node.js? 🟒

What is it? Node.js is NOT a language. It is a JavaScript Runtime Environment. It allows you to execute JavaScript code on a server, outside of a browser.

How it works: It uses Chrome's powerful V8 JavaScript Engine (the same one used in Google Chrome) to compile JS code into machine code that your computer understands.

2. Browser vs. Node.js 🌍

They both speak JavaScript, but they have different "superpowers" (APIs).

| Feature | Browser JS | Node.js | | :--- | :--- | :--- | | DOM Access | βœ… Yes (document, window) | ❌ No (No HTML/CSS) | | File System | ❌ No (Security risk) | βœ… Yes (Read/Write files) | | Global Object | window | global | | Modules | ES Modules (import) | CommonJS (require) & ES Modules |

3. Running Your First Node Script πŸƒβ€β™‚οΈ

You don't need an HTML file anymore. You run JS files directly using the terminal.

  1. Create a file named app.js.
  2. Write some code.
  3. Run node app.js in your terminal.
JAVASCRIPT PLAYGROUND
⏳ Loading editor…

4. Node.js Globals 🌐

Since there is no window, Node gives us other global variables.

  • global: The equivalent of window.
  • __dirname: Path to the current directory.
  • __filename: Path to the current file.
  • process: Info about the current Node.js process.
JAVASCRIPT PLAYGROUND
⏳ Loading editor…

5. Non-Blocking I/O (The Secret Sauce) ⚑

Node.js is famous for being Non-Blocking and Asynchronous.

Imagine a waiter in a restaurant:

  • Blocking (PHP/Java/Python classic): Waiter takes an order, waits for the chef to cook it, serves it, and ONLY THEN takes the next order. (Slow!)
  • Non-Blocking (Node.js): Waiter takes an order, gives it to the chef, and IMMEDIATELY takes the next order. When food is ready, the chef rings a bell (Callback). (Fast!)
JAVASCRIPT PLAYGROUND
⏳ Loading editor…

AI Mentor

Confused about "Node.js runtime, V8 engine, non-blocking I/O, and global objects"? Ask our AI mentor for a simplified explanation.

Quiz

Quiz

Question 1 of 4

What is Node.js?

A new programming language
A JavaScript framework like React
A JavaScript Runtime Environment
A database

Key Takeaways

βœ… Node.js runs JS on the server.
βœ… Uses Chrome V8 Engine.
βœ… No DOM (window is gone, global is here).
βœ… Non-Blocking architecture makes it fast for I/O.

What's Next?

Node.js has a massive ecosystem of libraries. Let's learn how to install them using NPM (Node Package Manager)!

Keep coding! πŸš€