Ubuntu comes with a pre-installed version of node and npm. To update it to the latest stable version run the following commands in your terminal.
Installing the latest stable npm version
To install the latest stable version of npm on your machine run the following commands in your terminal.
npm install -g npm@latest
To check the version of npm installed on your machine simply type the following command.
npm -v
Installing the latest stable Node version
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
This will install the latest stable version of Node on your Linux (Ubuntu) machine.
To check the version node installed on your machine simply type the following command.
node -v
Installing Yarn
Ubuntu does not come pre-installed with Yarn hence we have to install it. Run the command given below in your terminal.
npm install --global yarn
If this doesn't work try using the sudo
keyword with it.
sudo npm install --global yarn
To check the version node installed on your machine simply type the following command.
yarn -v