How to Install NodeJS on MacOS
Last Updated : 12 Dec, 2024
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
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.
Node.js InstallerStep 2: Run the Installer
Run .pkg Installer for Node.js and click "continue" once the wizard is open.
.pkg fileStep 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
Complete the InstallationStep 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:
TerminalNow you can check the version of the node package manager by executing the following command:
$ npm -v
npm -vThus, 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):
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
UpdateStep 3: Proceed to Install Node.js
Now run the following command to install Node.js:
Install nodejsbrew install node
Step 4: Verify the Installation
Now run the following command to verify the installation:
node -v
npm -v
verifyYour 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
macosThis command installs NVM and sets up the necessary configuration files.
Step 2: Restart Terminal
After the installation, restart your Terminal or run:
Terminalsource ~/.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:
Node.jsnvm 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
defaultStep 5: Verify Installation
Check the installed version of Node.js:
node -v
npm -v
verifyMethod 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.
Visit the official websiteStep 2: Install Node.js
Once MacPorts is installed, open Terminal and run:
sudo port install nodejs18
demoStep 3: Verify Installation
After installation, check the Node.js version:
node -v
npm -v
verifyHow 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.
Similar Reads
How to Install NuPIC on MacOS?
NuPIC stands for Numenta Platform for Intelligent Computing is a platform that implements the HTM (Hypertext Markup Language) learning algorithm. HTM is a detailed computational theory of the neocortex. At the core of HTM are timeframe continuous learning algorithms.NuPIC is used for a variety of pr
1 min read
How to Install C# on MacOS?
C# is a programming language that is used for general purposes. But the C# programming language is classified as one of the High-Level programming languages. Unlike the C programming language, the C# programming language can be used in other tasks. There might be a significant similarity between the
4 min read
How to Install ReactJS on MacOS
Are you looking to set up ReactJS on your Mac? Whether youâre using a MacBook Air, MacBook Pro, iMac, or any macOS version like Monterey, Ventura, Big Sur, or macOS 15 Sequoia, this step-by-step guide is here to help. ReactJS, the popular JavaScript library for building dynamic user interfaces, requ
4 min read
How to Install Node.js on Linux
Installing Node.js on a Linux-based operating system can vary slightly depending on your distribution. This guide will walk you through various methods to install Node.js and npm (Node Package Manager) on Linux, whether using Ubuntu, Debian, or other distributions. PrerequisitesA Linux System: such
6 min read
How to Install LISP on MacOS?
Lisp is one of the oldest programming languages. It was invented back in the 1950s by John McCarthy. Lisp is a so-called meta-programming language or a symbolic programming language. It can be used for any sort of task. It's a general-purpose language. It is the second-oldest high-level programming
1 min read
How to Install Julia on MacOS?
Julia is one of the new programming languages that is becoming popular with time. It is used mainly for scientific data calculations and mathematical analysis. It is becoming popular because it has very fast execution like C and simple syntax like python. It is an open-source language with high perf
2 min read
How to install Solidity on macOS?
Solidity is a programming language used for writing smart contracts for many platforms of blockchain, the most common of which is ethereum. It is an object-based programming language that runs on EVM (Ethereum Virtual Machine) which executes the smart contracts. Below are the steps to install solidi
2 min read
How to Install Golang on MacOS?
Before, we start with the process of Installing Golang on our System. We must have first-hand knowledge of What the Go Language is and what it actually does? Go is an open-source and statically typed programming language developed in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson at Google but
4 min read
How to Install Rasterio on MacOS?
In this article, we will learn how to install Rasterio in Python on MacOS. Rasterio is used to access geospatial raster data. Geographic information systems use GeoTIFF and other formats to organize and store gridded raster datasets such as satellite imagery and terrain models. Rasterio reads and wr
2 min read
How to Install Node.js on Windows
Installing Node.js on Windows is a straightforward process, but it's essential to follow the right steps to ensure smooth setup and proper functioning of Node Package Manager (NPM), which is crucial for managing dependencies and packages. This guide will walk you through the official site, NVM, Wind
6 min read