How To Install and Use NVM on Ubuntu Linux

|

|

The article provides a detailed guide on installing and using nvm (node version manager) on Ubuntu Linux. Nvm, a version manager for node.js allows developers to install, manage, and quickly switch between multiple node.js versions on the same system using command line, enhancing project-specific execution. The article also includes precise instructions on installing, updating, activating…

This article describes installing and using nvm (node version manager) on Ubuntu Linux.

Nvm is a version manager for node.js, designed to be installed per user and invoked per shell. It can install and manage node.js packages on Linux, macOS, and Windows with WSL.

If you are a developer and want to install and manage multiple versions of node.js on the same system and use a specific version for a specific project, you can use nvm.

Nvm also lets you quickly install and use different versions of nodes via the command line.

Below is how to install nvm on Ubuntu Linux.

How to install nvm on Ubuntu Linux

As mentioned above, nvm allows you to quickly install and use different versions of nodes via the command line.

The steps below show you how to do that on Ubuntu Linux.

Install nvm

To install or update nvm, you should run the install script. To do that, you may either download and run the script manually or use the following cURL or Wget command.

cURL command:

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

Wget command:

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash

Either of the commands above should download the nvm install script that can be used to install. 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).

After installing, the script should output the lines below.

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

Once downloaded, you can then activate and reload your shell environment. By default, it’s bash (~/.bashrc).

source ~/.bashrc

To check the version of nvm installed, run the commands below.

nvm --version

Install Node.js with nvm

As mentioned above, nvm can be used to install and manage node.js.

Run the commands below to download and install the current and latest version of node.js.

nvm install node

Once installed, you can check the version of node.js installed by running the commands below.

node --version

Run the commands below to install the latest stable version (long-term support).

nvm install node --lts

To install a specific version (12.17.0), run the commands below.

nvm install 12.17.0

To list all available versions in the repository, run the commands below.

nvm ls-remote

If you have multiple versions of node.js installed, run the commands below to specify the version you want to use.

nvm use 12.17.0

To find the current default node.js installed, run the commands below.

nvm run default --version

Uninstall node.js

To uninstall node.js, run the commands below.

nvm uninstall v12.17.0

That should do it!

Conclusion:

This post showed you how to install and use nvm on Ubuntu Linux. Please use the comment form below if you find any errors above or have something to add.


Discover more from Geek Rewind

Subscribe to get the latest posts to your email.

Like this:



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.

Discover more from Geek Rewind

Subscribe now to keep reading and get access to the full archive.

Continue reading