You've successfully subscribed to StackInk
Great! Next, complete checkout for full access to StackInk
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.

How to Update Node.js Versions on Mac?


Diving into the world of Node.js development, you'll inevitably need to update your Node.js version on your Mac. With an ever-evolving technological landscape, staying up-to-date with the latest releases is crucial, ensuring your projects run smoothly and efficiently. This comprehensive guide will walk you through updating Node.js on your Mac clearly and easily.

First, let's check your current Node.js version. To do this, launch Terminal and type the following command:



node -v


With the version now identified, it's time to choose an appropriate method to update Node.js. There are two popular ways: Node Version Manager (NVM) and Homebrew.

  1. Node Version Manager (NVM)


Utilizing NVM is a versatile option for managing multiple Node.js versions on your Mac. If you haven't installed NVM yet, follow these simple steps:

a. Run the following curl command in your Terminal to download and install NVM:


curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

b. Now, restart your Terminal and verify the installation with:


command -v nvm

You're all set to use NVM for Node.js version management!

To update Node.js using NVM, follow these steps:

a. List all available Node.js versions by entering:


nvm ls-remote

b. Identify the desired version from the list, and install it with:


nvm install <version_number>


c. Finally, set the newly installed version as the default:


nvm alias default <version_number>

Voilà! Your Node.js version has been successfully updated using NVM.

2. Homebrew


Homebrew is another reliable package manager for macOS, simplifying the installation and management of various software. Assuming you have Homebrew installed, updating Node.js is a breeze.

a. First, ensure Homebrew is up-to-date by running:


brew update

b. Then, upgrade Node.js to the latest version with:


brew upgrade node


And there you have it! Node.js has been updated using Homebrew.

It's crucial to update your Node.js on your Mac, whether you use the versatile NVM or the ever-reliable Homebrew, to ensure optimal performance and compatibility. With this comprehensive guide, you'll be well-equipped to keep your Node.js environment up-to-date, secure, and efficient. Happy coding!