Cantech Knowledge Base

Your Go-To Hosting Resource

How to Install Node.js and NPM on Ubuntu 24.04?

Node.js is an open-source, cross-platform JavaScript runtime environment which enables the development of scalable server-side applications and Node Package Manager (NPM) is an important tool for managing libraries, dependencies, and scripts in a Node.js project.
Together they help empower developers to create dynamic and efficient applications.

This blog explains how to install node.js and NPM on Ubuntu 24.04.

Note: If you’re on Debian 11 or 12, follow our dedicated Debian 11 and Debian 12 installation guides.

Prerequisites

Before you begin, check if the below requirements are met:

  • SSH Access with Sudo Privileges – Needed to run administrative commands.
  • Ubuntu 24.04 LTS – This guide is specific to that version of Ubuntu.
  • Basic Understanding of  Terminal Commands – This will help you to get through the installation steps successfully.
  • Stable Internet Connection – Needed to download repositories and packages.
  • System Package Updates – You will need to update the package index in the steps of the installation below.

Installation of NodeJS

The Ubuntu 24.04 APT repositories consist of a pre-installed Node.js package that may not be the latest version. Here is how you can install or update to the latest package.

Update Package Index

Before installing the latest software. It is ideal to update your package index to ensure you get the newest versions available.

$ sudo apt update

This command syncs the local list of packages with the repository.

Install NodeJs

Install NodeJs directly by using APT. Use the below command to install NodeJs and other dependencies.

$ sudo apt install nodejs

Verify and View the Installation

Check the installed version of NodeJs to verify if the installation is successful

$ node -v

Installation of NPM

Update Package Index

Update your package index to ensure you get the latest versions.

$ sudo apt update
sudo apt upgrade -y

Install NPM

To install NPM follow the below commands

$ sudo apt install npm

Verify the NPM Installation

To verify if the installation is successful. Run the below command.

$ npm --version

Methods for Installing Node.Js & NPM On Ubuntu

Here’s a way to install both NodeJs and NPM together on Ubuntu

Method 1 – By using the official repository for NodeJs and NPM installation on Ubuntu.

Run the Command

sudo apt install nodejs npm

Create a Symbolic Link

Here the node js uses binary path /usr/bin/node but our installed path is /user/bin/nodejs so we may get an error like “No path or directory found” if we don’t create a symbolic link and run the below command.

ln -s /usr/bin/nodejs /usr/bin/node

Check if Nodejs and NPM is installed or not

node --version
npm --version

Method 2 – By using NodeSource Repository for Node.js and npm Installation on Ubuntu.

Install Curl

We need to install curl so we can download third party repositories easily. For this we will run the below command.

sudo apt update
sudo apt install -y curl

In case, if it is pre-installed, it will display “already installed”, otherwise it will go ahead to install it for you.

Curl the Source Directory

We need to curl the source directory to install NodeJs and NPM. So, follow the below command.

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\
sudo apt-get install -y nodejs

This command will installs NodeJs and NPM

Method 3 – By using the NVM method for installing NodeJs and NPM

Install NVM

We need to curl and install NVM, to do this run the below command.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

Check if the NVM is installed

To check if the NVM is successfully installed, run the following command.

command -v nvm

List Versions and Choose

List all the versions that are available and choose the one that is perfect for your requirement, to do this run the below command.

nvm list-remote

Once this is done, run the following command to install your preferred version.

nvm install <version-name>

Use the Installed Version

Now run the below command and mention the version you want to use.

nvm use <your-installed-version-number>

Finally you have successfully installed and switched to your preferred version of NVM.

Conclusion

The process of installing NodeJs and NPM on Ubuntu 24.04 is easy. By following the above mentioned steps, you can start working on your projects right away. Take advantage of the power of NodeJs and NPM to begin your next JavaScript project. For a reliable server environment to run your applications, you can explore our Node.js Hosting.

FAQ’s

How to force npm install?

Force Installation with –force or -f flag

The –force flag will ignore any warnings and continue with the installation and this is helpful in cases where warnings prevent the installation, but it should be used with caution.

What is the difference between Node.js and npm modules?

Node.js is a piece of code that can be reusable and it encapsulates the related functionality. It can be a one single file or a collection of many files organized in a directory. Modules help in organizing code into manageable and small pieces to promote modularity and reuse of code.

Do I need to install a node for npm?

Node.js and the npm command line interface must be installed using either a Node version manager or a Node installer to publish and install packages to and from the public npm registry or a private npm registry, you must install Node.js and the npm command line interface using either a Node version manager or a Node installer.

September 15, 2025