1. Install NVM
$ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
=> Downloading nvm from git to '/home/johnnychu/.nvm'
=> Cloning into '/home/johnnychu/.nvm'...
remote: Counting objects: 267, done.
remote: Compressing objects: 100% (242/242), done.
remote: Total 267 (delta 31), reused 86 (delta 15), pack-reused 0
Receiving objects: 100% (267/267), 119.47 KiB | 1.61 MiB/s, done.
Resolving deltas: 100% (31/31), done.
=> Compressing and cleaning up git repository
=> Appending nvm source string to /home/johnnychu/.bashrc
=> Appending bash_completion source string to /home/johnnychu/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
2. Verify NVM Installation
$ source ~/.profile
$ nvm ls-remote
...
v8.11.3 (Latest LTS: Carbon)
v9.0.0
v9.1.0
v9.2.0
v9.2.1
v9.3.0
v9.4.0
v9.5.0
v9.6.0
v9.6.1
v9.7.0
v9.7.1
v9.8.0
v9.9.0
v9.10.0
v9.10.1
v9.11.0
v9.11.1
v9.11.2
v10.0.0
v10.1.0
v10.2.0
v10.2.1
v10.3.0
v10.4.0
v10.4.1
v10.5.0
...
3. Install NodeJS
$ nvm install 10.5.0
Downloading and installing node v10.5.0...
Downloading https://nodejs.org/dist/v10.5.0/node-v10.5.0-linux-x64.tar.xz...
##################################################################################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v10.5.0 (npm v6.1.0)
Creating default alias: default -> 10.5.0 (-> v10.5.0)
4. Verify NodeJS Installation
$ node -v
v10.5.0
5. Uninstall NodeJS
$ nvm current
v10.5.0
$ nvm uninstall v10.5.0
https://github.com/creationix/nvm
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04