Skip to main content

What is Node.js?

Node.js lets you run JavaScript outside of a web browser. Without it, JavaScript can only run inside a browser tab. With it, you can run JavaScript files from your terminal, use build tools, and install packages. You need Node.js for two things in this course:
  1. Running JavaScript files during the learning sections
  2. Running React’s development server when you build UIs
Node.js also comes with npm (Node Package Manager), which you’ll use to install libraries like React. You get both when you install Node.js.

Installation

The easiest way is with Homebrew:
brew install node
If you don’t have Homebrew, install it first from brew.sh, or download the installer directly from nodejs.org.
Always install the LTS (Long Term Support) version. It’s the stable release that won’t surprise you with breaking changes.

Verifying installation

Open your terminal and run these two commands:
node -v
# v20.11.0 (or similar)

npm -v
# 10.2.4 (or similar)
If both commands print a version number, you’re good to go. The exact version numbers don’t matter as long as Node.js is version 18 or higher.
If you get “command not found,” your terminal might not see the installation yet. Try closing and reopening your terminal. On Windows, you may need to restart your computer.

Quick test

Let’s make sure Node.js actually works. Type this directly in your terminal:
node -e 'console.log("Node.js is working!")'
# Node.js is working!
The -e flag lets you run a one-line JavaScript command without creating a file. You’ll create proper files in the next lessons.

What’s next?

Node.js is installed. Now let’s set up VS Code with the right extensions for JavaScript development.

Setting up VS Code

Configure your editor for JavaScript