Node.js is an essential tool for developers looking to use JavaScript for server-side programming. If you’re a Mac user, installing Node.js is simple and can be done in just a few steps. Whether you’re new to Node.js or need to set it up again, this guide will walk you through everything you need to know to install Node.js on mac and get started with your projects.
Why Install Node.js on Mac?
Node.js allows you to run JavaScript outside of the browser, enabling you to build scalable server-side applications. With its event-driven, non-blocking I/O model, Node.js is perfect for real-time applications, APIs, and microservices.
If you’re working on full-stack development or building JavaScript-based web applications, Node.js is a powerful tool to have in your developer toolkit. macOS, being a Unix-based operating system, provides an excellent environment for running Node.js, making it an ideal platform for developers.
Step-by-Step Guide to Install Node.js on Mac
There are a few methods to install Node.js on macOS, including using the official installer or Homebrew, a package manager for macOS. Below, we’ll cover both methods so you can choose the one that works best for you.
Method 1: Installing Node.js Using the Official Installer
Step 1: Download the Node.js Installer
- Go to the official Node.js download page.
- You will see two versions of Node.js available for download: LTS (Long Term Support) and Current. If you’re a beginner or looking for a stable version, it’s recommended to choose LTS.
- Click on the macOS Installer option to download the
.pkg
file.
Step 2: Run the Installer
- Once the
.pkg
file is downloaded, double-click on it to start the installation process. - Follow the on-screen instructions in the installer wizard.
- Click Continue and agree to the license agreement.
- Choose the installation destination (the default location is fine for most users) and click Install.
Step 3: Verify Installation
Once the installation is complete, you can verify that Node.js and npm (Node Package Manager) were installed correctly.
- Open the Terminal on your Mac.
- To check the version of Node.js, type:bashCopy
node -v
- To verify npm (which is included with Node.js), type:bashCopy
npm -v
You should see the version numbers for both Node.js and npm, confirming that the installation was successful.

Method 2: Installing Node.js Using Homebrew (Package Manager)
Homebrew is a popular package manager for macOS that simplifies the installation of software. If you prefer using Homebrew to manage your software installations, here’s how you can install Node.js.
Step 1: Install Homebrew (if you haven’t already)
If Homebrew is not already installed on your Mac, you can install it by running the following command in the Terminal:
bashCopy/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
This command will install Homebrew on your system.
Step 2: Update Homebrew
Once Homebrew is installed, run the following command to make sure Homebrew is up to date:
bashCopybrew update
Step 3: Install Node.js
With Homebrew updated, you can now install Node.js by running:
bashCopybrew install node
Homebrew will download and install the latest stable version of Node.js and npm for you.
Step 4: Verify Installation
After the installation is complete, you can verify it by checking the versions of Node.js and npm:
bashCopynode -v
npm -v
If you see the version numbers displayed, you’ve successfully installed Node.js using Homebrew.
Troubleshooting Common Installation Issues on macOS
While the installation process is usually smooth, here are a few common issues and their solutions:
1. Permission Issues
If you encounter permission issues during the installation process, try running the installer or the Homebrew command with sudo
for elevated privileges. For example:
bashCopysudo brew install node
2. Conflicting Versions
If you already have Node.js installed, you may want to ensure you’re using the latest version. You can use nvm (Node Version Manager) to manage multiple versions of Node.js on your system. To install nvm, run:
bashCopycurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Then, you can install and switch between different versions of Node.js using nvm.
3. npm Not Installed
If npm isn’t installed with Node.js, it could be due to a failed installation. Re-running the installation or using Homebrew often resolves this issue. If you’re using nvm, you can install npm manually with:
bashCopynvm install-latest-npm
4. Using Older macOS Versions
If you’re running macOS 10.9 or earlier, you might need to install an older version of Node.js. Use the Node Version Manager (nvm) to install a compatible version for older macOS versions.
Conclusion
Install Node.js on mac is simple and can be done through the official installer or using Homebrew, depending on your preference. Once installed, you’ll be ready to start building fast, scalable applications with Node.js. Whether you’re working on backend projects, full-stack development, or simply learning JavaScript, Node.js is a powerful tool that will help you build efficient applications.
If you encounter any issues, remember to check the troubleshooting section or consider using nvm for easier management of multiple Node.js versions. Now, you’re all set to get started with your Node.js projects on macOS!
Read Also : How to Install Node.js on Linux?