DEV Community

Sonu kumar
Sonu kumar

Posted on

Simplified Guide to Installing NVM on Ubuntu

Guide to Installing NVM on Ubuntu

Introduction

Managing multiple versions of Node.js on your Ubuntu system is crucial for development. Node Version Manager (NVM) simplifies this process, allowing you to switch between different versions effortlessly.

Step-by-Step Installation

  1. Update Your System: ```

sudo apt update


2. **Install Curl**:
Enter fullscreen mode Exit fullscreen mode

sudo apt install curl


3. **Download and Install NVM**:
Enter fullscreen mode Exit fullscreen mode

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash


4. **Activate NVM**:
Enter fullscreen mode Exit fullscreen mode

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" # This loads nvm


5. **Verify NVM Installation**:
Enter fullscreen mode Exit fullscreen mode

nvm --version


6. **Install Node.js Using NVM**:
Enter fullscreen mode Exit fullscreen mode

nvm install node


7. **Set Default Node.js Version**:
Enter fullscreen mode Exit fullscreen mode

nvm alias default node


8. **Check Installed Node.js Version**:
Enter fullscreen mode Exit fullscreen mode

node --version


#### Managing Node.js Versions

- **Install Specific Version**:
Enter fullscreen mode Exit fullscreen mode

nvm install


- **Switch Node.js Version**:
Enter fullscreen mode Exit fullscreen mode

nvm use


- **List Installed Versions**:
Enter fullscreen mode Exit fullscreen mode

nvm ls


- **Uninstall Node.js Version**:
Enter fullscreen mode Exit fullscreen mode

nvm uninstall


#### Conclusion
Using NVM on Ubuntu provides flexibility and control over your Node.js environment, making development smoother and more efficient. 

To know how to install the NVM on Windows please have a look:
[How to install NVM(Node Version Manager) on Windows](https://dev.to/mesonu/how-to-install-nvmnode-version-manager-on-windows-2ij1)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/skqz3ml9uk79n5q89eyu.png)



To learn about the Docker basics please have a look:
[What is Docker and why do we use it?](https://medium.com/@me.sonu300/what-is-docker-and-why-do-we-use-it-c86b11559b3b)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)