Lesson 1 of 20

Introduction to Node.js

What is Node.js?

Node.js is a JavaScript runtime built on Chrome's V8 engine that allows you to run JavaScript outside the browser — on servers, desktops, and IoT devices. It was created by Ryan Dahl in 2009 and has since become one of the most popular backend technologies.

Unlike traditional server-side languages that create a new thread for every request, Node.js uses a single-threaded, event-driven, non-blocking I/O model. This makes it lightweight, efficient, and ideal for data-intensive real-time applications.

The V8 engine compiles JavaScript directly to machine code, making Node.js extremely fast. Combined with its event loop architecture, Node.js can handle thousands of concurrent connections with minimal overhead.

  • Server-Side JavaScript — Run JavaScript on the server, not just in the browser
  • V8 Engine — Google's high-performance JavaScript engine compiles JS to machine code
  • Event-Driven — Uses an event loop to handle asynchronous operations efficiently
  • Non-Blocking I/O — Operations don't block the main thread, enabling high concurrency
  • NPM Ecosystem — Access to over 2 million open-source packages
Example
// Your first Node.js program
console.log('Hello from Node.js!');

// Node.js gives you access to system-level features
const os = require('os');
console.log('Platform:', os.platform());
console.log('CPU Cores:', os.cpus().length);
console.log('Free Memory:', Math.round(os.freemem() / 1024 / 1024), 'MB');
Notes
  • Node.js is not a programming language — it is a runtime environment that lets you execute JavaScript outside the browser.

Node.js Use Cases

Node.js excels in I/O-heavy applications where many simultaneous connections need to be handled. Its non-blocking architecture makes it perfect for real-time applications, APIs, and microservices.

Companies like Netflix, LinkedIn, PayPal, and Uber use Node.js in production. Netflix reduced startup time by 70% after migrating to Node.js, and PayPal saw a 35% decrease in average response time.

  • REST APIs and GraphQL servers
  • Real-time applications (chat, live updates, collaborative tools)
  • Microservices architecture
  • Command-line tools and build systems
  • Server-side rendering (Next.js, Nuxt.js)
  • IoT and streaming applications
Notes
  • Node.js is not ideal for CPU-intensive tasks like heavy computation or image processing. For those, consider using worker threads or offloading to other services.