The best way to install the latest Node.js on Ubuntu

There are many ways to install Node, but for the latest version you cannot use apt install or apt-get install.

The best way is to use the Node Version Manager (nvm) to install Node.

Note that there is no Ubuntu package for nvm and nvm is not a regular binary, but rather a shell function.

Note also that nvm is not meant to be used with sudo ! The install will be for your current regular user.

Before installing: make sure to have a .bash_profile file in your home directory.

The following steps will install nvm and node (and hence npm).

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

Reload your terminal.

Find the latest version listed by the following command:

nvm ls-remote

At the time of writing the latest was 9.5.0, so:

nvm install 9.5.0

nvm use 9.5.0

Check that the latest versions of node and npm are ready:

node -v

npm -v

Leave a Reply

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