How to Install NodeJS on MacOS
Node.js is a popular JavaScript runtime used for building server-side applications. It’s cross-platform and works seamlessly on macOS, Windows, and Linux systems. In this article, we'll guide you through the process of installing Node.js on your macOS system.
What is Node.js
Node.js is an open-source, cross-platform runtime environment that allows you to execute JavaScript code outside of a web browser. It is built on Chrome’s V8 JavaScript engine and is widely used for developing scalable network applications, web servers, real-time applications, and much more.
Refer to this article to learn more: Node.js Introduction
What is NPM
NPM (Node Package Manager) is a package manager for Node.js that helps developers install, share, and manage libraries and tools required for their Node.js applications. It’s an integral part of the Node.js ecosystem and is automatically installed along with Node.js.
How to Install Node on MacOS - 4 Methods
Now, we'll go through all the possible steps to understand how to download and install Node.js on MacOS
Table of Content
Method 1: Download and Install Node.js from Official Website
Follow the below steps to install Nodejs on MacOS from its official website.
Step 1: Download the Node.js Installer
Download Node.js from this link. You will see two versions: LTS and the latest version. Select the LTS (Long-Term Support) version because it is supported for the long term and is a stable version.
Step 2: Run the Installer
Run .pkg Installer for Node.js and click "continue" once the wizard is open.

Step 3: Finish the Installation
Follow the on-screen instructions and complete the installation process. After installation completion, this window will show up, click on the "close" button

Step 4: Verifying Node.js Installation
Verify the Node.js Installation by running the following command in the Terminal:
$ node -v
If Node.js was properly installed, you'll see something close to (but probably not exactly) this:

Now you can check the version of the node package manager by executing the following command:
$ npm -v

Thus, by following these 4 simple steps, you can easily download and install node in macOS.
Method 2: Install Node.js using Homebrew
Homebrew is the most common package manager used on macOS for managing open-source software. It's easy to use and ensures that you get the latest stable version of Node.js. Let's check them step-by-step to download NodeJS.
Step 1: Install Homebrew
Open Terminal and run the following command to install homebrew version 23.3.0 (if you haven’t already):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Update Brew
Once Homebrew is installed, make sure it’s up-to-date by using the following command:
brew update

Step 3: Proceed to Install Node.js
Now run the following command to install Node.js:

brew install node
Step 4: Verify the Installation
Now run the following command to verify the installation:
node -v
npm -v

Your system is now ready for Node.js
Method 3: Install Node.js using NVM
NVM (Node Version Manager) is a tool that allows you to install and manage multiple versions of Node.js. It's ideal if you need to switch between different versions of Node.js for different projects.
Step 1: Install NVM
Open Terminal and run the following command to install NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

This command installs NVM and sets up the necessary configuration files.
Step 2: Restart Terminal
After the installation, restart your Terminal or run:

source ~/.bashrc
Alternatively, for zsh users:
source ~/.zshrc
Step 3: Install Node.js with NVM
Now that NVM is installed, you can install the latest LTS version of Node.js:

nvm install 20
Step 4: Set a Default Version
If you want to set the default version of Node.js to a specific version, run:
nvm use 18
nvm alias default 18

Step 5: Verify Installation
Check the installed version of Node.js:
node -v
npm -v

Method 4: MacPorts to Download and Install Node.js
MacPorts is another package manager for macOS that allows you to install and manage software. If you are using MacPorts, follow these steps to install Node.js:
Step 1: Install MacPorts
If MacPorts isn’t installed on your system, you can download it from the official MacPorts website.

Step 2: Install Node.js
Once MacPorts is installed, open Terminal and run:
sudo port install nodejs18

Step 3: Verify Installation
After installation, check the Node.js version:
node -v
npm -v

How to Update Node.js on macOS
It’s essential to keep your Node.js installation up to date to benefit from the latest features, improvements, and security fixes.
If you installed Node.js via the official website, you can download the latest version manually from the official website and install it.
Case I: If you used Homebrew, you can update Node.js using the following command:
brew upgrade node
Case II: If you used NVM, you can update Node.js by first installing the latest version
nvm install node
Now, set it as the default version using:
nvm use node
Latest Node.js Version Updates (for macOS)
- LTS Version: The current LTS version of Node.js is 22.12.0
- Current Version: The latest current version is Node.js 23.3.0, which includes the latest features but may not be as stable as the LTS version.
- NVM: For users who need flexibility in managing multiple versions of Node.js, NVM is the best choice. It allows for seamless switching between versions, helping you work with different versions for different projects.
Installing Node.js on macOS is easy and can be done using multiple methods, including Homebrew, the official installer, and NVM. By following this guide, you'll have Node.js up and running smoothly on your macOS machine in no time.