Introduction
Node.js is one of the most popular open-source platforms that you can easily use to build your backend or rest API that can easily scale because it can handle simultaneous connections which supports a non-blocking, event-driven server, due to its single-threaded nature.
As the team continues doing some upgrades, some of our programs are still stuck in the old version of node.js which sometimes we encounter some issues when we are trying to update from the latest version.
In this tutorial, I will show you how to install different nodejs version while not messing up you're current server or development setup.
STEP 1
To install or update your NVM, you should run the install script. To do that, use the following cURL or Wget command:
As of the time of writing, we are using NVM v0.38.0
or
STEP 2
After running the above commands, it's time to add a variable to your bash command. Normally, it was located from these file paths:
~/.bash_profile
~/.zshrc
~/.profile
~/.bashrc
Using nano or vim, open one of the files above. For example i will be using ~/.bash_profile
Then paste the code below, then hit crtl + o + enter then ctrl + x to close the file.
Then source ~/.bash_profile
to set up environment for NVM:
STEP 3
To check the available lists of available node version that you can use. Type this command.
You will see a long lists of available version up-to the latest. Something like this below:
NVM can install any of these versions available in the list. For example, to install version v16.2.0, type:
To install the latest stable version, type:
To switch to any version installed by nvm.
NOTE
In case you've encounter errors such as glibc or glibcxx error not found, I got a solution for you pare. Please check our tutorial here: NVM installed, Getting GLIBC and GLIBCXX Error on Linux
Voila!!!
I hope you enjoy our tutorial, Let me know incase you encounter any error I would love to answer that. Don't forget to subscribe to my Youtube Channel at Let's Code Pare - Youtube Channel