# clean the cache
$ sudo npm cache clean -f
# install `n` package if not yet installed
$ sudo npm install -g n
# download and use latest stable version
$ sudo n stable
# download and use an arbitrary version
$ sudo n 6.0.0
# check node version
$ node -v
Note: terminal might have to be restarted for changes to take effect