Node.js is a popular JavaScript runtime that allows you to run JavaScript on the server side, and npm (the Node.js Package Manager) is a tool that helps you manage packages and dependencies for your projects. In this tutorial, we will show you how to install Node.js and npm on Ubuntu 22.04 with the latest version.
How do I install node.js on ubuntu 22.04 | 20.04 | 18.04
Before we begin, it’s a good idea to update your package manager’s package list. To do this, open the terminal and run the following command:
sudo apt update
This command updates the package list for the package manager, which is a list of available packages and their versions. You can now install Node.js and npm Linux systems.
Once the package list is up to date, you can proceed with the installation of Node.js and npm by running the following command:
#install latest node js ubuntu
sudo apt install nodejs
This will install both Node.js and npm. The installation process may take a few minutes to complete.
How do I install npm on ubuntu 22.04 | 20.04 | 18.04
Once the installation is complete, you can verify that Node.js and npm have been successfully installed by running the following command to print the version number of Node.js:
#install node js ubuntu
node -v
You should see the version number of Node.js that you installed.
You can also check the version of npm by running:
#install npm ubuntu
npm -v
This will show the version number of npm that you installed.
Congratulations! You now have Node.js and npm installed on your Ubuntu 22.04 system.
Note: You can read the manual of node.js by:
man node
You can now use npm to install packages and dependencies for your projects, or you can use Node.js to run your JavaScript code.
How to install node.js on ubuntu and update npm to the latest version?
One thing to note is that the version of Node.js that is available in the default Ubuntu 22.04 repositories (12.x) is not the latest version. If you want to install the latest version of Node.js 18.x LTS and NPM 8.19 (at the time of writing), you can follow the instructions in the official Node.js documentation: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions (install latest node and npm ubuntu)
Node.js Binary Distributions: https://github.com/nodesource/distributions/blob/master/README.md
How to install node.js on ubuntu and update npm to the latest version?
You can uninstall node js ubuntu by running this command:
sudo apt remove nodejs
it’ll remove the node.js from your ubuntu system excluding the configuration files.
The Short Note:
I hope this tutorial has helped you install Node.js and npm on Ubuntu 22.04. Let me know if you have any questions or encounter any issues during the installation process.