What is Node.js?

Node.js is a JavaScript runtime that lets you run JavaScript outside the browser. Even for β€œvanilla” JS projects, it’s useful for local dev servers, build tools like Vite, and package management.

Installation

macOS

# Using Homebrew (recommended)
brew install node

Or download the LTS installer from nodejs.org.

Windows

  1. Download the LTS installer from nodejs.org
  2. Run the installer with default settings
  3. Restart your terminal after installation

Linux

# Debian/Ubuntu
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs
 
# Fedora
sudo dnf install nodejs
 
# Or use nvm (recommended for managing versions)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
nvm install --lts

Verify Installation

node --version
npm --version

Quick Start with Vite

Vite is a fast dev server and build tool. Great for quickly scaffolding a project:

npm create vite@latest my-game -- --template vanilla
cd my-game
npm install
npm run dev

Your project will be running at http://localhost:5173.

Project Structure

A typical vanilla JS project:

my-game/
β”œβ”€β”€ index.html
β”œβ”€β”€ style.css
β”œβ”€β”€ main.js
β”œβ”€β”€ package.json
└── node_modules/

Useful Commands

npm install           # install dependencies
npm run dev           # start dev server
npm run build         # build for production
npm run preview       # preview production build