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