How to Update Node.js to Latest Version on Mac

Jul 2, 2024 - 1 Comment

You can update node.js to the latest version on a Mac by using the command line Homebrew tool

If you use Node.js for web development, creation of web apps, and javascript based network applications, you undoubtedly may come across situations where you’d like to make sure that the latest version of Node.js is installed on your Mac. Upgrading to the latest version of Node.js means you’ll have access to the most recent features and security updates available.

Assuming you have installed Node.js and npm with Homebrew (which implies you have also already installed Homebrew on the Mac too), which is arguably the easiest way to install node.js onto a Mac and to manage the javascript runtime environment, then you will find that updating Node.js to the latest version is really quite simple once you learn how.

How to Upgrade Node.js to the Latest Version on Mac with Homebrew

One of the many benefits of using Homebrew to manage command line software is that it’s not only easy to install packages, but also to update them, manage them, and even uninstall them from the Mac. For our purposes here, we’re going to demonstrate how to make sure that Node.js is updated to the latest version by using Homebrew. To get started, open the Terminal or your command line app of choice.

Optional, but not necessary, is to first check which version of node.js and npm you have installed on the Mac, which is possible with the following command:

node -v && npm -v

Now, you will want to update Homebrew, so that Homebrew itself can retrieve the latest versions of software:
brew update

After brew update has ran, you will want to run the brew upgrade command next. You can use brew upgrade for all packages installed with Homebrew, which is recommended, or you can specify only upgrading node.js, whichever you prefer:

Install updates to all Homebrew packages:
brew upgrade

OPTIONALLY, only install and upgrade to the latest Node.js version via Homebrew:
brew upgrade node

After the upgrade command has executed, you’ll now want to run the npm update command, with the install and -g flag to install the updates globally to the npm command itself, which looks like this:

npm install -g npm

After that has completed, you can confirm that node.js and npm have been upgraded to the latest versions by running the following command string again:

node -v && npm -v

And there you have it, you have now installed the latest available versions of Node.js and npm on the Mac, and verified that the latest version is installed, all with the ease of the Homebrew package manager.

Technically you can also install and upgrade node.js manually with a package installer too, but with how convenient Homebrew is to manage command line utilities and apps on the Mac, it really is the simplest way to go.


Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS, Tips & Tricks

One Comment

» Comments RSS Feed

  1. Han says:

    Cakebrew is the GUI for Homebrew.

Leave a Reply


Shop on and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks


iPhone / iPad



Shop on Amazon to help support this site