You've successfully subscribed to StackInk
Great! Next, complete checkout for full access to StackInk
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.

How to install Node.js and npm on Ubuntu 23.04?

Node.js is an open-source JavaScript runtime environment that is used to execute server-side scripts, and NPM is a package manager for Node.js. The following instructions will assist you in installing Node.js and NPM on Ubuntu 23.04.

Step 1:

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

Step 2:

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

Step 3:

Run the following command to verify that Node.js has been installed correctly:

node -v

The version number of Node.js should appear, indicating that the installation was successful.

Step 4:

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:

npm -v

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.