How to install Node.js and npm using NVM on Ubuntu and Fedora

Node.js is a free, open source JavaScript runtime environment. You can use it to run or run JavaScript code outside a web browser and run it as a standalone application. Npm (Node Package Manager) is the default package manager for Node.js and the online database of packages. NVM – Node Version Manager makes it easy to install and manage one or more versions of Node.js on your system. This is the recommended way to install Node.js and npm. Use this method to install NVM, Node.js, and npm on any Linux distribution, not just Ubuntu or fedora.

Install Node.js and npm using Node Version Manager NVM

Install NVM.
Open a terminal and run this NVM node version manager installation script.

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

Or you can install with cURL

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

In this script, v0.35.3 is the nvm version number. You can change this based on this Latest nvm version.

Close the terminal and reopen it. Run this to verify the nvm installation.

nvm --version

Install Node.js and npm.

Recommended Reading: ScreenCloud Screenshot Taking and Sharing Tool-How to Install ScreenCloud on Ubuntu

You can run this command to install the latest version of Node.js.

nvm install node

If you want to install a specific node.js version, first use this command to find the available Node version.

nvm ls-remote

Then, if you want to install v12.16.2, use this command to install.

nvm install 12.16.2

List the installed node versions. Close the terminal, then open it and run it.

nvm list

How to install Node.js and npm using NVM on Ubuntu and Fedora

You can run this command to set the default Node.js version. Enter the version number below the command.

nvm use v12.16.2

You can check the default version with this command.

node --version

You can use this command to uninstall a specific version of node.js. You are now uninstalling v13.13.0 from your system.

nvm uninstall v13.13.0

npm comes with node.js. Downloading and installing Node.js will automatically install npm on your system. You can use this command to see the installed npm version.

npm -v

It’s the kind of thing

.

Sidebar