JavaScript Needs A Runtime Environment
JavaScript by itself does very little. The language gives you numbers, strings, arrays, objects, functions, and loops. It has no way to draw anything, read a file, or talk to a network. Every useful thing JavaScript does comes from the program providing JavaScript with what we call a runtime environment.
In Google Chrome, the browser acts as the JavaScript runtime environment. At its core, Chrome runs JavaScript using an engine called V8, which compiles and executes the base language. However, V8 alone cannot interact with the outside world. To turn this engine into a complete runtime environment, Chrome injects its own Web APIs directly into the execution context.
In 2009 Ryan Dahl took V8, the same engine out of Chrome, and wrapped it in a different program. That program handed JavaScript a different set of abilities: read and write files, open network connections, start other programs, read the arguments someone typed on a command line. He called it Node.js.
🟠The part worth holding onto
The same JavaScript you write for a web page is the language Node runs, with identical syntax. What changes is what the language is allowed to touch: a web page in the browser, and your computer in Node.
What Node Has That A Browser Does Not
The file system
Node can read, write, rename, and delete files anywhere the user account is allowed to. A browser deliberately cannot, because a web page you have never visited before is not something you want reading your documents.
Processes
Node can start other programs and read what they printed. Chaining several tools into one command depends entirely on this.
Servers, not only clients
A browser opens connections to servers. Node can be the thing listening. This is how a local development server exists at all.
The command line
Node scripts receive arguments and environment variables, and hand back an exit code. That is what lets a JavaScript file work as a command line tool.
While both environments execute the same core JavaScript, the browser runtime focuses on user interface and security, whereas the Node.js runtime prioritizes system access and server utility.
/* This works in a browser and crashes in Node */
document.querySelector('h1');
/* This works in Node and crashes in a browser */
import { readFileSync } from 'node:fs'; Seeing It For Yourself
Node and npm install as commands that can run inside a terminal. You can open a terminal and ask it what version it is. This not only shows the current versions but it also checks that node and npm are available for your project.
node --version
npm --version Having Node installed allows you to run JavaScript files as programs. For example, here is a simple JavaScript file called hello.js that is written for Node:
/* hello.js */
console.log('Running in:', process.version);
console.log('This folder:', process.cwd()); node hello.js
Running in: v24.19.0
This folder: /Users/jake/Projects/hello There is no HTML file and no browser involved, and the output lands in the terminal. process is one of the objects Node hands to JavaScript, and it describes the running program itself: which version of Node, which folder it started in, what the user typed to launch it.
Things Node Is Not
Not a framework
Node has no opinion about how to structure an app. It runs whatever JavaScript it is given.
Not a web server
Node can be used to write a web server, and many people have. Installing Node does not start one.
Not a language
The language is JavaScript. Node is a program that runs it.
Not part of the browser
Nothing about installing Node changes how Chrome or Firefox behaves.
Not required to write a website
Plain HTML and CSS work with no Node anywhere. Node is required for the tools, not for the web.
Not the only option
Deno and Bun run JavaScript outside the browser too. Node is the oldest and by far the one most documentation assumes.
Why This Is The Foundation Of The Toolchain
Once JavaScript could read files and start programs, developers could write their tools in the same language they were already writing their websites in. That is why the web toolchain ended up made of JavaScript. Not for any technical advantage, but because every front-end developer already knew the language, and Node removed the reason they could not use it for tools.
Every tool in the rest of this lab is a JavaScript program that Node runs. The next page covers the program that fetches those tools and keeps track of them.