A Comprehensive Guide to Updating Node.js on macOS

January 18, 2024

1 minute read

Keeping your Node.js version up-to-date is crucial for leveraging the latest features and security enhancements. While updating on Windows is straightforward, updating Node.js on macOS may seem a bit more involved than on Windows, but fear not! In this guide, we’ll walk you through the process step by step.

Step 1 - Check your Node.js version

Open you console/terminal and execute the following command::

node -v

This will display your current Node.js version as ‘v x.x.x.’

Step 2 - Install ‘n’ package using npm

To make the update process smoother, we’ll use the ‘n’ package, a straightforward Node.js version manager. Execute the following command to install ‘n’ globally using npm:

sudo npm install -g n

Step 3 - Update your Node.js version

Now that ‘n’ is installed, updating Node.js is a breeze. Choose one of the following commands based on your preference:

  • To install the latest LTS Node.js release version:

    sudo n lts
    
  • To install the latest Node.js release version

    sudo n latest
    
  • To install specific Node.js version

    sudo n x.x.x
    

Step 4 - Verification

That’s it! Ensure the update was successful by checking your Node.js version again:

node -v

The terminal should display the updated Node.js version as ‘v x.x.x.’

Now you’re all set with the latest Node.js version, equipped to make the most of the newest features and improvements. Happy coding!