8 January 2022

How to Install Node.js and NPM on Mac

Install Node.js and NPM on Mac, using the Homebrew package manager. This simple tutorial walks you through all the necessary steps.


Node.js is a popular back-end JavaScript runtime used for creating web servers and scalable network apps. The environment supports server-side scripting - producing dynamic content for web pages before they are served to the user.

NPM is a package manager for JavaScript and the default package manager for Node.js. As such, NPM is installed alongside Node.js as a recommended feature.

This tutorial will show you how to install Node.js and NPM on Mac using the Homebrew package manager.


Note: Node.js has a PKG installer for macOS available on its website. However, installing with Homebrew is the recommended approach.

Install Homebrew

1. To install Homebrew on macOS, browse to Homebrew's official website and follow the instructions.

2. Open the terminal and paste the command. Type the sudo password when prompted. Lastly, confirm that you want to install Homebrew by pressing Return.

Note: For other operating systems, refer to appropriate tutorials on installing Node.js and NPM on Windows, Ubuntu and CentOS.

1. Type the following command to install Node.js and NPM:

brew install node

Homebrew downloads and installs the dependencies.

2. When the installation finishes, confirm that you successfully installed Node.js by checking its version:

node -v

The system displays the Node.js version as the output of the command.

Node.js version
The node.js version number is displayed.

3. Next, check the installed version of NPM by typing:

npm -v
NPM version
The NPM version number is displayed.

Update Node.js and NPM on Mac

1. Before you proceed with upgrading the Node.js installation, update Homebrew's repositories by typing:

brew update

2. When the update completes, type the following command:

brew upgrade node

The output in the example shows that the newest version of Node.js is already installed on the system.

Uninstall Node.js and NPM on Mac

1. Uninstall both Node.js and NPM with the brew uninstall command:

brew uninstall node

2. Remove all the unused dependencies with:

brew autoremove

This command removes the packages that brew uninstall did not remove.


After reading this tutorial, you should know how to use Homebrew to install Node.js and NPM on macOS.

Thanks for taking the time to read this!

If you enjoyed it, and think others would benefit from the read then feel free to share it on Twitter (or elsewhere). I’m always up for a discussion about anything I’ve written too, so get in touch if you want to chat!

If you’ve spotted something out of place or something needs correcting, feel free to let me know.

A newer entry How to switch between Node.js versions with Homebrew

18 January 2022 In this tutorial I'll show you the easiest way to switch between Node.js versions on macOS. To do so, we will use the Homebrew package manager and install and configure it.

An older entry Dynamically Changing a Netlify Form Name

18 March 2021 Netlify forms are easy to use because they are simple in scope. Add a little power with this cool trick.