Updating Nodejs

These are three simple steps to update Nodejs in Ubuntu using npm:

  • Clean the npm cache first: sudo npm cache clean -f
  • Install npm’s n module: sudo npm install -g n
  • Update node verison using the n: sudo n stable

Confirm the Nodejs version: node -v

NOTE:

npm itself can be updated in the following way – 

npm install npm@latest -g