Installing
Node.js
on
Ubuntu
Arguably the most basic and repeated task for any Node developer is installing Node.js on a server. So it makes sense to find the quickest way to do it. The solution is node version manager or nvm. NVM makes it easy to install any version of node or multiple versions of node on the same server.
Installing NVM
Installing NVM is easy. Just enter the following command into your terminal.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
You will see a line telling you to close and reopen your terminal. This is not necessary you can instead use this command.
source ~/.profile
Run the following command to get a list all available versions of node.js.
nvm ls-remote
Installing Node.js
Run this command to install the latest stable version of node.
nvm install stable
Check the installed version of node with this command.
node -v
Optional steps
You have now installed node.js with nvm. If you would like to use a different version of node.js can specify the version with.
node use v10.9.0