
Node.js is a server-side JavaScript language based on the V8 JavaScript engine from Google. Node.js allows you to write server-side JavaScript applications. It provides an I/O model based on events and non-blocking operations that enables you to write efficient applications. Node.js is known for its large modular ecosystem through npm. This guide will take you through the steps of installing Node.js 14 on Ubuntu 22.04|20.04|18.04.
Node.js 14 was released on 2020-04-21 and is expected to enter active LTS state on 2020-10-20. The maintenance window will start on 2021-10-19 and is expected to reach End-of-life on 2023-04-30.
For CentOS / RHEL installation: Install Node.js 14 on CentOS & RHEL
Install Node.js 14 on Ubuntu 22.04|20.04|18.04
We will use the Node.js Binary Distributions installer script to setup Node.js 14 on Ubuntu 22.04|20.04|18.04 Linux system.
Step 1: Update APT index
Run the apt update command on your Ubuntu Linux to update package repository contents database.
sudo apt update
Step 2: Install Node.js 14 from package
After system update, install Node.js 14 on Ubuntu 22.04|20.04|18.04 by first installing the required repository.
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
The script above will create apt sources list file for the NodeSource Node.js 14.x repo:
# Ubuntu 20.04 example
$ cat /etc/apt/sources.list.d/nodesource.list
deb https://deb.nodesource.com/node_14.x focal main
deb-src https://deb.nodesource.com/node_14.x focal main
Once the repository is added, you can begin the installation of Node.js 14 on Ubuntu Linux:
sudo apt -y install nodejs
Verify the version of Node.js installed.
$ node -v
v14.21.3
Step 3: Install Node.js Dev Tools
If you need Node Development tools, install them with the command:
sudo apt -y install gcc g++ make
To install the Yarn package manager, run:
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
Checking Yarn version:
$ yarn -V
yarn install v1.22.19
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 0.10s.
You have covered the simple steps required to install Node.js 14 on Ubuntu 22.04|20.04|18.04. Have fun with your backend software development.
Thank you so much for laying out this. I am trying to learn coding on a Chromebook and your guide is/was spot on. Many thanks.
Welcome and thanks for the comment.
Thank you.
Just what i needed.
Welcome
thanks mate
Welcome
Doesn’t work for Ubuntu 22.04.1 Jammy for Desktop
It fails at the apt install part
We have tested on Ubuntu 22.04 and it works. Check if you have another version of Node installed.
I get the following error when running:
$ sudo apt -y install nodejs
…
Preparing to unpack …/nodejs_14.21.3-deb-1nodesource1_amd64.deb …
Unpacking nodejs (14.21.3-deb-1nodesource1) over (12.22.9~dfsg-1ubuntu3) …
dpkg: error processing archive /var/cache/apt/archives/nodejs_14.21.3-deb-1nodesource1_amd64.deb (–unpack):
trying to overwrite ‘/usr/share/systemtap/tapset/node.stp’, which is also in package libnode72:amd64 12.22.9~dfsg-1ubuntu3
Errors were encountered while processing:
/var/cache/apt/archives/nodejs_14.21.3-deb-1nodesource1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
any help would be appreciated!
Try running the commands below and share feedback:
sudo apt purge nodejs
sudo apt autoremove
sudo apt install nodejs
Also
sudo apt remove libnode72 && sudo apt install nodejs
It installed v18 not v14 as expected
Did you add the repos as in the guide?