You should have a non-root user account with sudo privileges set up on your system. You can do so by running the following command:

$ sudo usermod -aG sudo [YOUR_USERNAME]

Replace "[YOUR_USERNAME]" with the user you are currently logged in as. This command adds your user to the sudo group.

Installing NVM

An alternative to installing Node.js with apt is to use a tool called nvm, which stands for “Node.js Version Manager”. You can install multiple self-contained versions of Node.js without affecting the entire system.

Use curl to download the nvm installation script from theproject’s GitHub page:

$ curl -sL -o

Run the script with bash:

$ bash

Source the ~/.profile file so that your current session knows about the changes:

$ source ~/.profile

To check which version of NVM is installed, type:

$ nvm --version

The output will be something like:


It is recommended that you install either LTS or current version of Node. The latest LTS version is v12.18.3. You can install that by typing:

$ nvm install 12.18.3

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

$ nvm use 12.18.3

To check if Node is installed, type:

$ node -v 

The output will be something like this: