Hi Guys, Welcome to Proto Coders point. Here is a quick step by step guide to update nodejs in ubuntu OS.
Time needed: 3 minutes
update node version
- use n module
To upgrade node version in ubuntu will make use of n module from npm package.
- Install n module
Firstly install n module using npm run below command.
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
…so now we have successfully install n module of npm package. - update node version ubuntu to latest
Now simply run below command, to upgrade nodejs and to update npm version.
sudo n latest
Note: this will update your nodejs and npm version to latest version(not to stable current version). - Now check nodejs version
run below command
node --version
npm --version
- Optional – update node to specific version
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node
If node --version
showing you old version still then simply, close and re-open new terminal and run node --version
to check nodejs version updated or no.