All posts
4 min read

What Is Node.js? JavaScript Outside the Browser, Explained

Node.js lets JavaScript run on servers and on your computer, and it's behind npm, most AI-built backends, and tools like Claude Code's ecosystem. What Node.js is, what it's used for, LTS versions, how to install it properly, and the errors beginners hit first.

getting startedtoolingno-codebeginner

JavaScript was created to run inside web browsers. Node.js took it out of the browser, so the same language can run on servers, on your laptop, and in command-line tools. If your AI-built app has a backend, there's a good chance it's running on Node.

What Node.js is

Node.js is a runtime: a program that runs JavaScript code. It's built on V8, the JavaScript engine from Google Chrome, plus extras a browser doesn't have — reading and writing files, starting network servers, running other programs.

When you run:

node server.js

Node reads server.js and executes it, just as Python runs a .py file.

What people use it for

  • Web servers and APIs. The backend of your app — handling logins, talking to the database, calling Stripe. Frameworks like Express, Fastify, and Next.js run on Node. (Frontend vs Backend.)
  • Build tools. Even apps with no backend use Node during development to bundle and optimise code. Vite, which powers many Lovable and Bolt projects, is a Node tool.
  • Command-line tools. Many developer tools are Node programs.
  • Scripts and automation. Small jobs like resizing images or importing a CSV.

Its main strength: one language for the front end and back end.

npm comes with it

Installing Node also installs npm, the package manager — the tool that downloads libraries your project depends on, listed in package.json. npm install, npm run dev, and npx all come from here. (npm and package.json Explained.)

Versions and "LTS"

Node releases a new major version every six months. Even-numbered versions become LTS — long-term support — and receive fixes for about three years. Odd-numbered versions are short-lived.

Use the current LTS version unless your project says otherwise. As of this writing that's Node 24. Check which version a project expects:

node --version       # which Node you have
cat .nvmrc           # some projects pin a version here

And look for an "engines" field in package.json.

Version mismatches cause a surprising share of "it works on my machine" problems. A project written for Node 24 may fail in odd ways on Node 18. (Why Does My App Work Locally but Not in Production?.)

Installing it properly

You can download an installer from nodejs.org. Most developers instead use a version manager, which lets you switch between Node versions per project and avoids permission problems:

  • nvm (macOS / Linux) or nvm-windows
  • fnm — fast, cross-platform
  • Volta
  • mise — manages Node and many other tools

With nvm:

nvm install --lts
nvm use --lts

Avoid sudo npm install -g. If you get permission errors installing global packages, the fix is a version manager, not sudo.

A tiny Node server

Here's a complete web server:

import http from "node:http"

const server = http.createServer((req, res) => {
  res.writeHead(200, { "Content-Type": "text/plain" })
  res.end("Hello from Node!")
})

server.listen(3000, () => console.log("Listening on http://localhost:3000"))

Run it with node server.js and open localhost:3000. Frameworks like Express add routing and conveniences on top of exactly this. (What Is localhost?.)

Errors you'll meet first

  • command not found: node — Node isn't installed, or your terminal can't find it. Restart the terminal after installing.
  • Cannot find module 'express' — dependencies aren't installed. Run npm install.
  • Error: listen EADDRINUSE: address already in use :::3000 — something is already using that port, often an old copy of your app still running. Stop it, or use another port. (What Is an IP Address and a Port?.)
  • SyntaxError: Cannot use import statement outside a module — the code uses modern import syntax but the project isn't set up for it. Add "type": "module" to package.json, or ask your AI tool to make the style consistent.
  • EBADENGINE warnings — your Node version doesn't match what a package expects. Switch versions.

Node in production

On a server, Node apps need a few things your laptop doesn't:


EasySpawn workspaces come with Node.js ready, alongside Claude Code, so your app's backend, build tools, and scripts run in the same persistent environment you deploy from. See how it works or join the waitlist.

Related: What Is a Tech Stack? · What Is Next.js? · Writing a Production Dockerfile for a Node.js App

Keep reading