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 nodeOr download the LTS installer from nodejs.org.
Windows
- Download the LTS installer from nodejs.org
- Run the installer with default settings
- 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 --ltsVerify Installation
node --version
npm --versionQuick 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 devYour 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