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:
- Open your terminal
- Check if
nvm
is installed by runningnvm --version
. If you get a version number,nvm
is installed properly - Optionally: you can list the available Node.js versions by running
nvm ls-remote
- 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
- After installation, you can switch to the newly installed version by running:
nvm use 18.17.0
or usenvm use 18
to switch to the latest version 18 - Verify that the Node.js version has changed by running
node -v