How To Install NVM (Node Version Manager) on Ubuntu System?

Harish Kumar · · 24819 Views

This tutorial will assist you with installing NVM on the Ubuntu machine. Additionally, allow you to install different node versions and other useful examples.

NVM is a Node Version Manager tool. Using the NVM tool, you can install multiple node.js versions on a single system. You can likewise pick a particular Node version for applications. It also gives a choice to auto-select node version using the .nvmrc configuration file.

Installing NVM on Ubuntu

We will use curl to install NVM. So, make sure curl is installed on your system:

sudo apt install curl

Run the following command to install NVM, and make sure to replace v0.37.2 with the latest version of NVM.

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

 The script clones the nvm repository to ~/.nvm, and attempts to add the source lines from the snippet below to the correct profile file (~/.bash_profile~/.zshrc~/.profile, or ~/.bashrc).

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

Check the installed version, by running:

nvm --version

NVM commands

See  list all available node.js versions:

nvm ls-remote

Install latest LTS version of node:

nvm install --lts

Install a specific version of node:

nvm install 6.14.4 # or 10.10.0, 8.9.1, etc

See the list of installed node versions:

nvm ls

Switch to other installed node versions:

nvm use <your latest _working_ version from the ls>
0

Please login or create new account to add your comment.

0 comments
You may also like:

JavaScript Array .filter(): A Comprehensive Tutorial

JavaScript offers several powerful methods to manipulate arrays, and .filter() is one of the most versatile and commonly used. This tutorial will guide you through the basics of (...)
Harish Kumar

Vue 3: Best Practices for Efficient and Scalable Development

Vue.js is a popular JavaScript framework for building user interfaces. It has several features that enhance the development process and performance of applications. This guide (...)
Harish Kumar

JavaScript's Array .forEach() Method Explained: Tips, Tricks, and Examples

The array .forEach() method is one of the most powerful tools in JavaScript, used for executing a provided function once upon an array element. Common applications involve iterating (...)
Harish Kumar

Mastering JavaScript Performance: Techniques, Patterns, and Best Practices

JavaScript is the backbone of modern web applications, providing the interactivity and dynamic behavior that users have come to expect. However, as applications become more complex, (...)
Harish Kumar

React State Management: `useState` Hook vs. Class `setState()`

React provides two primary ways to manage state in components: the useState Hook for functional components and setState() along with this.state for class components. Both methods (...)
Harish Kumar

Mastering the `array.map` Method in JavaScript

The array.map method in JavaScript is a powerful and versatile function used to create a new array by applying a specified function to each element of the original array. It’s (...)
Harish Kumar