In this short tutorial, you will discover three ways to update NodeJs on Ubuntu 18.04 and 20.04.
Let’s start with NVM, Node Version Manager.
It is by far the best method to update NodeJS on Linux machines.
You will need a C ++ compiler, the package build-essential and the library libssl-dev. Run an update first, then we’ll install the packages.
sudo apt-get update
To install the packages, run the command :
sudo apt-get install build-essential checkinstall libssl-dev
How to install NVM: To install or update NVM, you can get the installation script using cURL:
curl -o https://raw.githubusercontent.com/creationix/nvm/v0.35.2/install.sh | bash
To check if the installation was successful, invoke the command :
nvm -v
The command will return the version of nvm if all goes well. Your Node JS update will become easy.
Read: How to install Node.js on Linux/Ubuntu
You can check which versions are currently installed with the command :
nvm ls
To see the latest npm version for installation, run the command :
nvm ls-remote
Download, install and compile the latest versions of Node JS using
nvm install #. #. # [update nodejs ubuntu]
Replace the #s with the required Node JS version.
If NVM didn’t work for you, a package manager is now your best alternative.
The Node Package Manager, or NPM, helps you discover, share, and use code, along with dependencies. Node JS comes with npm pre-installed, but it is updated more often than Node.
Run the command:
npm -v
To see what your current version is.
Now to install the latest version of npm, execute the command :
npm install npm@latest -g [install npm ubuntu]
Next invoke :
npm -v
Again to make sure that the update has been done correctly.
Now to update Node JS, you will need an npm module called “n”.
Run the lines of code below on your terminal to clear the npm cache, install the “n” module and install the latest stable version of Node JS.
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
To install the latest version, run the command :
sudo n latest
Or otherwise, you could also execute:
sudo n #. #. #
As it was the case with the first method, replace the #s with the required Node JS version.
If you are desperate and the other options didn’t work out, you can visit the official downloads page to get a 32-bit or 64-bit binary package.
You can install the package via the browser itself, but if you prefer to use the terminal, keep in mind that the specific version of the node may change while updates are released.
On your terminal, run the command:
wget https://nodejs.org/dist/v14.15.3/node-v14.15.3-linux-x64.tar.xz
To unzip the file, you will need the xz-utils package, to install it, run :
sudo apt-get install xz-utils
Now run the command below to extract and install the binary package in /usr/local:
tar -C /usr/local –strip-components 1 -xJf node-v14.15.3-linux-x64.tar.xz
The post How to update Node JS on Ubuntu 18.04 appeared first on net2.
Canonical’s Kubernetes LTS (Long Term Support) will support FedRAMP compliance and receive at least 12…
Welcome to the Ubuntu Weekly Newsletter, Issue 878 for the week of February 2 –…
At Canonical, we firmly believe that delivering an outstanding, customer-centric support experience is impossible without…
I want to share how to install osTicket v1.14 for Ubuntu 20.04 server. osTicket written…
Now I want to share how to install WordPress on ubuntu 20.04 server. WordPress is…
Now I want to share the DNS server installation process on your Ubuntu 20.04 server.…