To ensure you have the latest security updates and software versions, you should always update your system before installing any new software. Running the following commands will update your system:
sudo apt update sudo apt upgrade
Installing Node.js on Ubuntu 23 is straightforward. We will use the recommended method, which is to install it from the official NodeSource repository.
Run the following command to add the repository:
cd ~ curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh
This command will add the repository to your system as well as download the GPG keys necessary to verify the packages.
Upon adding the repository, you can install Node.js by running the following command:
sudo apt install nodejs
Run the following command to verify that Node.js has been installed correctly:
The version number of Node.js should appear, indicating that the installation was successful.
There is no need to install npm separately as node.js comes with npm. You can verify that npm is installed by running the following command:
If the installation was successful, you should see the version number of npm.
You're done! The installation of Node.js and npm on your Ubuntu 23 system has now been completed.