Ubuntu has this version of nodejs because it was one of the LTS versions (long term support) and is very stable.
There are a few different ways to install newer versions. I would recommend installing it through nvm so you get access to the latest versions. Plus it helps to do it this way if you will be developing on multiple systems rather than leaving it up to the systems package manager. To do this first remove the current version
sudo apt-get remove nodejs
To ensure it's completely removed you can do sudo apt-get purge nodejs
and sudo apt-get autoremove
Now we can prepare to use npm by installing build-essential
and libssl-dev
sudo apt-get install build-essential libssl-dev
Now we can download the nvm installation script from the projects Github page
curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh -o install_nvm.sh
Run the install script with
bash install_nvm.sh
At this point it is easiest to logout, and then log back in to complete the setup of npm.
Now we can use the following commands to install the target nodejs version
npm ls-remote
shows you the available versions
npm install (versionNumber)
npm use (versionNumber)
You can have multiple versions installed so you can choose which one to use
then verify the version you have chosen to use with
node -v
<- Please note that with npm the command is node and NOT nodejs
There is a great write up about all of this on Digital Ocean. For more information visit the link https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04