How to upgrade Node.js to the latest version on Mac OS?

Better Stack Team
Updated on March 11, 2024

To upgrade Node.js to the latest version on macOS, you can use a version manager like nvm (Node Version Manager) or directly download and install the latest Node.js version from the official website.

Using nvm (Node Version Manager)

If you have nvm installed, follow these steps:

  1. Open your terminal.
  2. Check the currently installed Node.js versions and identify the version you want to install by running:

     
    nvm ls
    
  3. To install the latest version, use the following commands:

     
    nvm install node --latest-npm
    

    This command installs the latest version of Node.js along with the latest npm.

  4. Once the installation is complete, set the default version:

     
    nvm alias default node
    
  5. Verify that Node.js has been updated by running:

     
    node -v
    

Without nvm (Direct Download):

If you don't use nvm and prefer to download and install Node.js directly:

  1. Visit the official Node.js website: https://nodejs.org/.
  2. Download the latest version of Node.js for macOS.
  3. Once the download is complete, open the installer and follow the installation instructions.
  4. After installation, open a new terminal window and verify that Node.js has been updated:

     
    node -v
    

Remember that using nvm provides flexibility to easily switch between different Node.js versions. If you encounter permission issues during the installation or need to manage multiple Node.js versions, nvm is a recommended solution.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github