How to install nodejs on ubuntu

Publish : 2022 May 25 959 view Cat : AVANETCO + Linux
install nodejs
5/5 - (2 votes)

As many of you may know nodejs popularity has risen in recent years. as it speeds up site loading time because everything is loaded on client side so we are going to see how to install nodejs on ubuntu

nodejs is usually used with nginx so we are going to cover nginx configuration in another post and skip to install nodejs

there are 3 methods to install nodejs we are going to use Node version manger or NVM. you can install it from linux repo with simple apt commands but the version in this repositories is quite old.

first we have to download latest version of NVM:

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

now load NVM in your current terminal:

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

to verify installation run nvm --version

now to install your preferred version run the command below and replace X with your version

nvm install XXXX

to execute nodejs : nvm use xxx

now you can create a test page using nodejs in root of nginx like the picture below

install nodejs