3 min read

A Step-by-Step Guide to Installing Node.js on macOS

Need Node.js on your Mac? You've got two solid options: the official installer for simplicity, or Homebrew for flexibility. Here's how to get it set up right, step by step.

J

Jamie

LogicCore Digital

A Step-by-Step Guide to Installing Node.js on macOS

So you're setting up a development environment on macOS and you need Node.js. Good news - installing it on a Mac is pretty straightforward. You've got two main paths: the official installer (simple, works for everyone) or Homebrew (preferred by most developers). Both get you Node.js and npm, but Homebrew gives you more flexibility if you're doing serious development work.

Let's walk through both methods so you can pick what works best for you.

What You'll Need

Before we dive in, make sure you've got these basics covered:

  • macOS: A reasonably recent version (macOS 10.15 Catalina or newer is generally recommended for the latest Node.js versions, though older macOS versions might support older Node.js releases).
  • Terminal Access: You'll need to be comfortable using the Terminal app (found in /Applications/Utilities/). Basic command-line knowledge helps.
  • Internet Connection: You'll be downloading Node.js, so a stable connection is essential.

(Optional but Recommended) Xcode Command Line Tools: Some Node.js packages might need to compile code during installation. Having the Xcode Command Line Tools installed can prevent potential headaches. You can install them by opening Terminal and running:

bash
xcode-select --install

Follow the on-screen prompts if they appear. If they're already installed, it'll let you know.

Method 1: Using the Official Node.js Installer

This is the simplest method - just download a standard macOS installer package (.pkg) and run it. Perfect if you want to get up and running quickly without dealing with package managers.

Step 1: Download the Installer

  1. Open your web browser and head to the official Node.js website: https://nodejs.org/
  2. On the homepage, you'll typically see two download buttons:
    • LTS (Long-Term Support): Recommended for most users. It's stable and supported for a longer period.
    • Current: Includes the latest features but might be less stable than LTS.
  3. Click the LTS button to download the macOS Installer (.pkg) file.

Step 2: Run the Installer Package

  1. Find the downloaded .pkg file (usually in your Downloads folder).
  2. Double-click it to launch the Node.js installer wizard.

Step 3: Follow the Installation Wizard

  1. Click through the installer screens by clicking "Continue".
  2. Agree to the software license agreement.
  3. Choose the installation location (the default is usually fine).
  4. Click "Install". You may be prompted to enter your administrator password to authorize the installation.
  5. Once installation completes, you'll see a confirmation screen. Click "Close".

Step 4: Verify the Installation

  1. Open the Terminal application (if it's not already open).

Check the installed npm version (npm is installed automatically with Node.js):

bash
npm -v

This should output the corresponding npm version (e.g., 10.2.4).

Check the installed Node.js version:

bash
node -v

This should output the version number you just installed (e.g., v20.11.1).

If both commands display version numbers, Node.js has been successfully installed using the official installer.

Homebrew is a popular package manager for macOS that makes installing and managing software a breeze. If you're doing development work, this is often the preferred method because it's easier to update, manage, and switch between versions.

Step 1: Install Homebrew (If Not Already Installed)

  1. Open the Terminal application.
  2. Check if Homebrew is already installed by typing:
bash
brew --version

If it's installed, you'll see a version number. If not, you'll get a "command not found" error.

If Homebrew isn't installed, paste the following command into your Terminal and press Enter. This command comes from the official Homebrew website (https://brew.sh/):

bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Follow the on-screen instructions. It might ask for your password and prompt you to install the Xcode Command Line Tools if you haven't already.

Step 2: Update Homebrew

It's good practice to make sure Homebrew is up-to-date before installing new packages. Run this in Terminal:

bash
brew update

Step 3: Install Node.js

Now install Node.js using Homebrew:

bash
brew install node

Homebrew will download and install the latest stable version of Node.js and npm.

Step 4: Verify the Installation

  1. Open a new Terminal window or tab (this ensures your shell recognizes the newly installed commands).

Check the npm version:

bash
npm -v

Check the Node.js version:

bash
node -v

If both commands display version numbers, Node.js has been successfully installed using Homebrew.

You're All Set

That's it! You've got Node.js and npm installed on your macOS computer using either the official installer or Homebrew. You're ready to start using Node.js for your projects, run JavaScript files from the command line, and manage project dependencies with npm.

Helpful Resources

Want to dive deeper? These official resources are worth bookmarking:

Published on April 21, 2025