ScriptsApr 13, 2026·3 min read

Node.js — The JavaScript Runtime Built on V8

Node.js is the open-source JavaScript runtime that enables server-side JavaScript execution. Built on Chrome V8, it uses an event-driven, non-blocking I/O model that makes it lightweight and efficient for building scalable network applications.

TL;DR
Node.js runs JavaScript server-side with event-driven, non-blocking I/O for scalable backends.
§01

What it is

Node.js is the open-source JavaScript runtime that enables server-side JavaScript execution. Built on Chrome's V8 engine, it uses an event-driven, non-blocking I/O model that makes it lightweight and efficient for data-intensive real-time applications. Node.js powers everything from REST APIs and CLI tools to full-stack web applications.

The target audience includes full-stack developers who want a single language across frontend and backend, DevOps engineers building tooling, and teams building real-time applications like chat servers or streaming platforms.

§02

How it saves time or tokens

Node.js unifies the language across the entire stack. Frontend developers write backend code without learning a new language. The npm ecosystem provides over two million packages, so most common tasks -- HTTP servers, database clients, authentication -- require installing a package rather than writing from scratch.

For AI-assisted development, Node.js's vast package ecosystem means LLMs have extensive training data for generating correct code. Token usage drops because standard patterns (Express routes, middleware, async/await) are well-established and require minimal explanation.

§03

How to use

  1. Install Node.js using a version manager:
# Install fnm (Fast Node Manager)
curl -fsSL https://fnm.vercel.app/install | bash
fnm install --lts
node --version
  1. Create a simple HTTP server:
// server.js
const http = require('node:http');

const server = http.createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'application/json' });
  res.end(JSON.stringify({ message: 'Hello from Node.js' }));
});

server.listen(3000, () => {
  console.log('Server running on http://localhost:3000');
});
  1. Run it:
node server.js
curl http://localhost:3000
§04

Example

A minimal Express API with async database access:

const express = require('express');
const app = express();

app.use(express.json());

app.get('/api/items', async (req, res) => {
  const items = await db.query('SELECT * FROM items LIMIT 20');
  res.json(items);
});

app.post('/api/items', async (req, res) => {
  const { name, value } = req.body;
  const result = await db.query(
    'INSERT INTO items (name, value) VALUES (?, ?)',
    [name, value]
  );
  res.status(201).json({ id: result.insertId });
});

app.listen(3000);
§05

Related on TokRepo

§06

Common pitfalls

  • Blocking the event loop with CPU-intensive synchronous code. Use worker threads or child processes for heavy computation.
  • Not handling promise rejections. Unhandled rejections crash the process in recent Node.js versions. Always use try/catch with async/await.
  • Using require() in ESM modules or import in CommonJS without configuring type: 'module' in package.json.
  • Neglecting to pin dependency versions. Use a lockfile (package-lock.json) and avoid wildcard version ranges in production.
  • Running Node.js without a process manager (PM2, systemd) in production. The process exits on uncaught exceptions with no auto-restart.

Frequently Asked Questions

What is the difference between Node.js and Deno?+

Deno is a newer runtime also created by Ryan Dahl (Node.js creator). Deno uses TypeScript natively, has built-in security permissions, and does not use node_modules. Node.js has a much larger ecosystem and broader industry adoption. Both run JavaScript on V8.

Should I use CommonJS or ES Modules in Node.js?+

ES Modules (import/export) are the modern standard and recommended for new projects. Set 'type': 'module' in package.json. CommonJS (require/module.exports) remains the default for backward compatibility. Most npm packages now support both.

How do I manage multiple Node.js versions?+

Use a version manager like fnm, nvm, or Volta. These tools let you install multiple Node.js versions and switch between them per project. fnm is the fastest option. Add a .node-version or .nvmrc file to your project root to pin the version.

Is Node.js suitable for CPU-intensive tasks?+

Node.js excels at I/O-bound workloads. For CPU-intensive tasks, use the worker_threads module to offload computation to separate threads. Alternatively, delegate heavy processing to native addons (C/C++) or external services.

How do I deploy Node.js in production?+

Use a process manager like PM2 for automatic restarts and clustering. Containerize with Docker for consistent environments. Deploy behind a reverse proxy (Nginx, Caddy) for TLS termination and static file serving. Set NODE_ENV=production to enable performance optimizations.

Citations (3)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets