Nodejs always installing 4.2.6

Hey guys if you have Ubuntu 16 try this instructions. It worked for me perfectly.Also provide your account password whenever asked in this process.

  1. sudo su -c "echo 'deb https://deb.nodesource.com/node_8.x xenial main' >> /etc/apt/sources.list.d/nodesource.list"

  2. sudo su -c "echo 'deb-src https://deb.nodesource.com/node_8.x xenial main' >> /etc/apt/sources.list.d/nodesource.list"

  3. sudo apt-get update

  4. apt-cache policy nodejs Check if the versions listed has node 8

  5. sudo apt-get install nodejs

  6. nodejs -v check the node version installed

This shall successfully install nodejs version 8 on your system. If you wish any other version, then change the version on step 1 and 2 it shall work successfully.


In Linux/Mac systems, there is no better way than nvm - Node Version Manager.

Install:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

Then, usage is as simple as:

nvm install 8.0
nvm use 8.0

If after reboot you will see old version, use nvm alias to set your version as default one.

Note: If you're a happy user of new M1 Apple chip, install version 15 of Node.js with nvm, it supports it out of the box.