logo

How to upgrade Node.js on your Mac OS

May 6, 2024

You can use several methods to upgrade your Node.js version on your Mac. One of the most common and efficient ways to achieve this is by using Node Version Manager (nvm).

nvm is a bash script that helps you install and manage multiple versions of Node.js. It allows you to switch between versions easily without affecting the entire system setup.

To check if nvm is installed, you can run nvm --version. If you get a version number, that means nvm is installed properly. If you receive an error message indicating that the command is not found, it means you haven't installed nvm yet. You can install it by following the instructions on the nvm GitHub page.

To update Node.js using nvm, follow the steps below:

  1. Open your terminal
  2. Check if nvm is installed by running nvm --version. If you get a version number, nvm is installed properly
  3. Optionally: you can list the available Node.js versions by running nvm ls-remote
  4. Install the newer Node.js version you need (e.g., in my case, I want to install 18.17.0) by running nvm install 18.17.0
  5. After installation, you can switch to the newly installed version by running: nvm use 18.17.0 or use nvm use 18 to switch to the latest version 18
  6. Verify that the Node.js version has changed by running node -v