VOOZH about

URL: https://www.geeksforgeeks.org/installation-guide/how-to-install-nodejs-on-macos/

⇱ Installation of NodeJS on MacOS - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Installation of NodeJS on MacOS

Last Updated : 28 Feb, 2026

Node.js is an open-source, cross-platform JavaScript runtime built on Chrome’s V8 engine. It enables developers to run JavaScript outside the browser and build scalable server-side and real-time applications.

  • Used for building server-side applications, web servers, and APIs.
  • Runs on macOS, Windows, and Linux using Chrome’s V8 engine.
  • Suitable for scalable and real-time networking applications.

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.

Installation

Follow these steps to install Node.js on your macOS system quickly and correctly.

Method 1: Download and Install Node.js from Official Website

To install Nodejs on MacOS from its official website follow the steps given below.

Step 1: Download the Node.js Installer

Visit the official Node.js website and download the installer. You will see two versions: LTS and Current. Choose the LTS (Long-Term Support) version, as it is stable and recommended for most users.

πŸ‘ macnode
Node.js Installer

Step 2: Run the Installer

Run .pkg Installer for Node.js and click "continue" once the wizard is open.

πŸ‘ mac21
.pkg file

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

πŸ‘ nodemac
Complete the Installation

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:

πŸ‘ nodemac2
Terminal

Now you can check the version of the node package manager by executing the following command:

 $ npm -v 
πŸ‘ npmmacos01
npm -v

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):

πŸ‘ brew
Brew
/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
πŸ‘ brew-ready
Update

Step 3: Proceed to Install Node.js

Now run the following command to install Node.js:

πŸ‘ brew9
Install nodejs
brew install node

Step 4: Verify the Installation

Now run the following command to verify the installation:

node -v
npm -v
πŸ‘ verify
verify

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
πŸ‘ mac20000
macos

This command installs NVM and sets up the necessary configuration files.

Step 2: Restart Terminal

After the installation, restart your Terminal or run:

πŸ‘ restart
restart
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:

πŸ‘ mac100001
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
πŸ‘ mac100002
default

Step 5: Verify Installation

Check the installed version of Node.js:

node -v
npm -v
πŸ‘ newimg

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.

πŸ‘ default21
Visit the official website

Step 2: Install Node.js

Once MacPorts is installed, open Terminal and run:

sudo port install nodejs18
πŸ‘ default
demo

Step 3: Verify Installation

After installation, check the Node.js version:

node -v
npm -v
πŸ‘ verify
verify

Updating Node.js on macOS

Update Node.js regularly to access new features and security fixes. If installed from the official site, download and reinstall the latest version.

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 (v24.x): Stable and recommended for production environments with long-term support and security updates.
  • Current (v25.x): Includes the latest features and improvements but has a shorter support cycle.
  • NVM: A version manager that lets you install and switch between multiple Node.js versions for different projects.
Comment