NodeJS is a popular javascript runtime environment which lets you run javascript code outside a browser. In this article we'll be installing NodeJS 20 on our system which is running Ubuntu 22(jammy).
If you want you can follow the instructions on official nodejs site also: https://nodejs.org/en/download/package-manager/current
You can check our Ubuntu version using either of the following commands:
lsb_release -a
OR
cat /etc/lsb-release
Step 1: Update packages
Run the following two commands to update and upgrade the packages, before we move forward
sudo apt update
sudo apt upgrade
This will ask you for the root password, enter it and let the process complete
Step 2: Install cURL (if not already installed)
We'll be using the curl command to install nodejs, so if it is already present on your system you can skip this step. To check if curl is present on your system run the following command
curl --version
If you see an output like command 'curl' not found, it means you need to install curl. To install curl run the following command
sudo apt install curl
After installation you can verify it by running the previous command again. If successfully installed, you will see a similar output
Step 3: Installing Node
To install node run the following two commands in terminal
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
nvm install 20
Running the above commands installs NodeJS v20 on our system. If you want, you can install any other version of node, you'll just need to specify that version. Say you want to install v18, you'll need to run the command nvm install 18
instead of nvm install 20
If you see a message like nvm not found, close the terminal and open it again. This should fix it.
Step 4: Verify
You can verify the node and npm (node package manager) version by running the following commands:
node -v # should print v20.12.2
npm -v # should print 10.5.0
I hope this article has helped you and you were able to follow along. If you are facing any trouble, comment down.
Thanks. Peace.
Top comments (0)