How To Install Nodejs On Ubuntu 18.04

Install using Node.js Version Manager (NVM)

1. Install & Update script

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 -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash

or

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

Running either of the above commands downloads a script and runs it.

2. Verify installation

To verify that nvm has been installed, do:

$ command -v nvm

which should output nvm if the installation was successful. After running the install script, if you get nvm: command not found or see no feedback from your terminal after you type command -v nvm, simply logout of your terminal, then log back in and try verifying again.

3. Install the latest release of node

To download, compile, and install the latest release of node, do this:

$ nvm install node

As of this writing, 10/30/2019, the latest version is 13.0.1

The first version installed becomes the default. New shells (each time you logout/log back in) will start with the default version of node.

You can list available versions using ls-remote:

$ nvm ls-remote

To install a specific version of node: as of this writing, 10/30/2019, the latest LTS is 12.13.0

$ nvm install 12.13.0

You can tell nvm to use the version you just downloaded by typing:

$ nvm use 12.13.0

To see the version of node currently being used:

$ node -v

REFERENCES

https://github.com/nvm-sh/nvm
https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04

Leave a Reply

Your email address will not be published. Required fields are marked *

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