What is NVM?
Published: 2024-02-05 02:53:03

**_Intoduction_**

With the use of Node.js, or node, we have the ability to have Javascript communicate with in a unified language in client/server side development.(1) The advantages that come with Node.js is the use of the Node Version Manager. 


_**Advantages of NVM**_

With nvm, you are allowed to change versions quick and easy. Nvm stores multiple versions that have associated modules inside your user directory.(2) You can, with the use of commands, see a list of the versions that have been installed, change the default, change to a specific version, and others.


**_How to install NVM in Ubuntu_**

First, you need to run the installer in your ternimal.
```javascript
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

# or

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
```
Depending on the commands available you can use either curl or bash. The directory for nvm will be installed. . If the configuration is not added automatically with the installation, you may add it yourself with the following command.(3)
```javascript
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
```
Next, run the command 
```javascript 
source ~/.zshrc || source ~/.bash_profile
```
This will reload the configuration for your terminal for use.


**_After Installation_**

You will need to have the most updated versions available for you to use. Run this command. 
```javascript
nvm install latest
```
The latest version of nvm will be installed. To check which versions you have installed run this command.
```javascript
nvm ls
```
A list of all the versions that have been installed with a description of which is set to default will show up. Here is an example.
```javascript
       v16.20.2
       v18.18.1
->       system
default -> v18.19.0 (-> N/A)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v18.18.1) (default)
stable -> 18.18 (-> v18.18.1) (default)
lts/* -> lts/iron (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2
lts/hydrogen -> v18.19.0 (-> N/A)
lts/iron -> v20.11.0 (-> N/A)
```
If you need to set the default to another version, run the command.
```javascript
nvm alais default [version]
```
You may need to leave the default where it is, but want to use a specific version. You can run this command.
```javascript
nvm use [version]
```
If there is a version that you need and you do not have it installed you can run this commad to get a specific version.
```javascript
nvm install [version]
```

**_Conclusion_**

We have taken a look into a few of the advantages of NVM. Also, there has been a step-by-step installation process for users of Ubuntu(Linux) based services. Last, we looked into how to check which version have been installed, change your default setting,
and choose a specific version to use. 



**_Reference Links_**
(1)https://www.baeldung.com/linux/update-nodejs-npm
(2)https://www.linode.com/docs/guides/how-to-install-use-node-version-manager-nvm/
(3)https://www.freecodecamp.org/news/node-version-manager-nvm-install-guide/