As a programmer i know the importance of Node Js in current scenario. So i am writing this post for all developers who are using ubuntu and wants to install nodeJs.
You can install Node Js using three ways
- Install Node.js from Default Apt Repository
- Install Node.js from Nodesource Repository
- Install Node.js using NVM
1. How to Install Node.Js on Ubuntu 22.04 using Default Apt Repository-
Ubuntu 22.04 default contains an old version of Node.js. Currently, the repositories contain the Node 12.22.9 version. but Today when i am writing this post, Node current version is 16.14.2
To install Node.js from default repositories, run:
$ sudo apt update && sudo apt install nodejs
2. Install Node.Js from NodeSource Repository-
For this method curl must be installed on your ubuntu system. Then add the NodeSource repository in your system using below command.
$ sudo apt install curl $ curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
And Now install the Node.js using the Apt package manager.
$ sudo apt update && sudo apt install nodejs
3. Install Node.Js using NVM-
A shell script is available for the installation of nvm on the Ubuntu 22.04 (Jammy Jellyfish) Linux system.
For this method also you need curl . Now using the below command we will install curl on our ubuntu system.
$ sudo apt install curl
Now run the nvm installer script.
$ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
The nvm installer script creates an environment entry to the login script of the current user.
$ source ~/.bashrc
Now you can install any version of Node.js on your system. Also it allows to install multiple Node.js versions on your system. Now we will install latest version of Node so as we know current LTS is 16.14.2.
$ nvm install 16.14.2
Now Node is installed on your system.
Your check by running command
$ node -v
Thanks and Happy Coding..
if you like this please share and comment.