A Step-by-Step Guide to Installing Node.js on macOS
Install Node.js on your Mac easily. This guide provides detailed steps for macOS users using the official .pkg installer or the popular Homebrew package manager. Includes prerequisites and verification.

Node.js is a powerful open-source environment that allows developers to run JavaScript code outside of a web browser. It's widely used for building fast, scalable backend services, command-line tools, and various web applications. Think of it as a way to use the popular JavaScript language for server-side tasks and more.
On macOS, installing Node.js is straightforward, and there are several methods available. This guide provides detailed steps for installing Node.js and its companion package manager, npm (Node Package Manager), on your macOS computer using the most common approaches: the official installer and the Homebrew package manager.
System Requirements (Prerequisites)
Before starting the installation, please verify that your computer meets these requirements:
- macOS Operating System: A reasonably recent version of macOS (e.g., macOS 10.15 Catalina or newer is generally recommended for the latest Node.js versions, but older versions might support older Node.js releases).
- Terminal Access: You need to be comfortable using the Terminal application (found in
/Applications/Utilities/
). Basic command-line knowledge is helpful.
(Optional but Recommended) Xcode Command Line Tools: Some Node.js packages (installed via npm) might need to compile code during installation. Having the Xcode Command Line Tools installed can prevent potential issues. You can install them by opening Terminal and running:
xcode-select --install
Follow the on-screen prompts if they appear. If they are already installed, it will let you know.
Method 1: Using the Official Node.js Installer
This method involves downloading a standard macOS installer package (.pkg
) directly from the official Node.js website.
Step 1: Download the Installer
- Open your web browser and navigate to the official Node.js website: https://nodejs.org/
- On the homepage, you'll typically see two download buttons:
- LTS (Long-Term Support): Recommended for most users. It offers stability and is supported for a longer period.
- Current: Includes the latest features but might be less stable than LTS.
- Click the LTS button to download the macOS Installer (
.pkg
) file.
Step 2: Run the Installer Package
- Locate the downloaded
.pkg
file (usually in yourDownloads
folder). - Double-click the file to launch the Node.js installer wizard.
Step 3: Follow the Installation Wizard
- Proceed through the installer screens by clicking "Continue".
- Agree to the software license agreement.
- Choose the installation location (the default location is usually recommended).
- Click "Install". You may be prompted to enter your administrator password to authorize the installation.
- Once the installation is complete, you'll see a confirmation screen. Click "Close".
Step 4: Verify the Installation
- Open the Terminal application (if it's not already open).
Type the following command and press Enter to check the installed npm version (npm is installed automatically with Node.js):
npm -v
This should output the corresponding npm version (e.g., 10.2.4
).
Type the following command and press Enter to check the installed Node.js version:
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.
Method 2: Using Homebrew (Recommended for Developers)
Homebrew is a popular package manager for macOS that simplifies installing software. If you plan on doing development work, Homebrew is often the preferred method.
Step 1: Install Homebrew (If Not Already Installed)
- Open the Terminal application.
- Follow the on-screen instructions provided by the Homebrew installer. It might ask for your password and prompt you to install the Xcode Command Line Tools if you haven't already.
If Homebrew is not installed, paste the following command into your Terminal and press Enter. This command is obtained from the official Homebrew website (https://brew.sh/):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Check if Homebrew is installed by typing:
brew --version
If it's installed, you'll see a version number. If not, you'll get a "command not found" error.
Step 2: Update Homebrew
It's good practice to ensure Homebrew is up-to-date before installing new packages. Run the following command in Terminal:
brew update
Step 3: Install Node.js
Now, install Node.js using Homebrew by running:
brew install node
Homebrew will download and install the latest stable version of Node.js and npm.
Step 4: Verify the Installation
- Open a new Terminal window or tab (this ensures your shell recognizes the newly installed commands).
Type the following command and press Enter to check the npm version:
npm -v
Type the following command and press Enter to check the Node.js version:
node -v
If both commands display version numbers, Node.js has been successfully installed using Homebrew.
Installation Complete
You have now successfully installed Node.js and npm on your macOS computer using either the official installer or Homebrew. You are ready to start using Node.js for your projects, run JavaScript files from the command line, and manage project dependencies with npm.
Further Reading & References
For more detailed information, you may find these official resources helpful:
- Official Node.js Website & Documentation: https://nodejs.org/
- Node.js Installation Guides (Official): https://nodejs.org/en/download/package-manager
- npm Documentation: https://docs.npmjs.com/
- Homebrew Website: https://brew.sh/
- (Advanced) NVM (Node Version Manager) - For managing multiple Node.js versions: https://github.com/nvm-sh/nvm