Node.js setup in Ubuntu

We will install node.js using NVM (Node Verify Manager). NVM is a version manager for node.js. First, we will install nvm and then using nvm, we will install node.js.

Install nvm

Run the following command to install nvm.

curl -o- | bash 

You can refer this source for more information -

Verify nvm installation

Run the following command and if it outputs "nvm" then it's installed successfully.

command -v nvm

List all available nodejs versions

Following command will list all available versions for node.js.

nvm ls-remote

Install node.js

Following command will install node.js. Note that we haven't mentioned any version in this command so it will install the latest available version.

nvm install node # install latest version

To install a specific version of node, we need to specify the version in the install command as below.

nvm install 6.14.4 # or 10.10.0, 8.9.1, etc

Verify node.js installation

Run the following command and it should display installed node.js version if it's installed successfully.

node -v 

List all installed versions

Using the following command, we can see a list of all installed node.js versions.

nvm ls

So here, we are done with setting up node.js in our ubuntu system.