I’m writing this post as I need to install node.js and npm to install packages for reveal.js, I’m on Ubuntu 18.04 Bionic.
Normally we can install node.js via terminal by
sudo apt install nodejs
But this is not the best way since the version is outdated and some dependencies won’t meet. The best way to install the latest node.js and npm is via nvm.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
Note that the version number can be checked by going directly to the website and see. The above script will download all the package and put nvm into the Linux alias (so we can use the nvm command globally). After this, log out and log in to activate the alias.
Once you log in, run below script
nvm install node
nvm install node nvm alias default nodenvm install node nvm alias default node
From this answer: https://askubuntu.com/a/1009527