How To Update Node Version On Mac Using Terminal?
In this article, I am going to share how to update the Node version on Mac using the terminal.
After a long search on the internet, I found partial solutions. Maybe they have worked for others, but they didn’t work for me. I am going to explain what I have done to upgrade my node version.
So, I was running v15.14.0 and I wanted to upgrade my node version to v16.15.0 which is a stable version as of the date I am writing this article.
Method 1: Using the n package (If it works for you)
The primary solution I found is:
-
Cleaning the NPM cache:
sudo npm cache clean -f -
Installing node package helper 'n':
sudo npm install -g n -
Install stable version of node:
sudo n stable
That’s it. The Node version is updated on your machine. BUT, it didn’t work on my machine.
Someone told me to reboot the terminal or machine to see the updated version, but it didn’t work either.
Method 2: Using NVM (Node Version Manager) - The Reliable Solution
Then, I searched for other solutions and I found one. NVM was already installed on my machine. So, when I ran:
nvm install v16.15.0
Boom! Node version updated successfully on my machine.
I am sharing this here because I have struggled a lot to do the same process before as well. This is going to help me as a reference in the future. There might be other developers facing similar issues who will find this helpful!
Happy Coding!