text: Q:
  
  How to update nodejs from 6.x to 8.x?
  
  Simple question - How to update nodejs from 6.x to 8.x? I have Ubuntu 16.04. Should I uninstall older version and install new one? If so, how can I do this. 
  A tried 
      sudo n latest
  but it says
      sudo: n: command not found
  and when i just 
      n latest
  is requires sudo
  Wtf?
  
  A:
  
  Use Node version manager:
  For development systems you may test different versions so you may want to switch between versions on demand. This is possible using the nvm version manager. This allows you to try out your code in different versions and find problems.
  Install it using the script:
  $ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
  
  Then you may directly use it. It can install other versions and switch between versions easily.
  Some of the commands are:
  nvm current     display currently activated version
  nvm ls [<version>]  list installed versions
  nvm ls-remote [<version>]   list versions available for install
  nvm version <version>   get best matching installed version
  nvm version-remote <version>    get best matching remote version
  nvm install <version>   download and install a version
  nvm uninstall <version>     uninstall a version
  nvm use <version>   modify path to use version
  nvm which <version>     show path there this version is installed
  
  So to install node 8 call
  $ nvm install 8
  
  And to upgrade to new node version later:
  $ nvm current
  v8.0.0
  $ nvm version-remote 8
  v8.1.0
  $ nvm install 8.1 --reinstall-packages-from=8.0
  Downloading and installing node v8.1.0...
  Downloading https://nodejs.org/dist/v8.1.0/node-v8.1.0-linux-x64.tar.xz...
  ######################################################################## 100,0%
  Computing checksum with sha256sum
  Checksums matched!
  Now using node v8.1.0 (npm v5.0.3)
  
  Reinstalling global packages from v8.0.0...
  added 9 packages and updated 1 package in 2.463s
  Linking global packages from v8.0.0...
  
  But after you changed your node version you should call npm install in your module again.
  
  A:
  
  Use this command for ubuntu   
  sudo npm install npm@latest -g
  sudo npm cache clean -f
  sudo npm install -g n
  sudo n stable
  
  //for latest release 
     `sudo n latest
  
  