In this tutorial we will guide you on how to setup/install Node.js and NPM on Ubuntu 22.04 environment.
Let us start the installation.
1 Update the system
Let us first update our system.
sudo apt update && apt upgrade -y
2 Installing Nose.js and NPM
The default Node.js version is 12.22.9 and NPM is 8.5.1. To install Node.js and NPM from the Ubuntu 22.04 repository run this commend.
sudo apt install nodejs npm -y
Check if successfully installed.
3 Installing Node.js from NodeSource
Another method in installing Node.js is using the NodeSource. In this method we will install Node.js version 18 using the curl command but If you want to install specific version you can check the NodeSource documentation.
The Node.js package from the NodeSource already include the NPM package manager so you don’t need to install it and to verify that.
4 Installing Node.js using the Node Version Manager
Another good way to install Node.js is using the Node Version Manager or NVM. The NVM will allow you to install multiple active independent version of Node.js. You can visit the NVM documentation on their Github page.