Yandex
Update cookies preferences

Installing Node.js on Debian and Ubuntu

Node.js is a powerful JavaScript-based platform that allows developers to create server-side applications with high performance. The main feature of Node.js is its asynchronous, event-driven architecture, which allows it to handle multiple requests simultaneously without blocking execution. This makes Node.js ideal for developing scalable web applications such as chat rooms, games, and streaming services. In addition, Node.js uses a single-threaded model, which makes code development and debugging much easier. Thanks to the extensive npm (Node Package Manager) ecosystem, developers have access to thousands of libraries and modules, which speeds up the application development process. Node.js also supports real-time handling of real data, making it particularly attractive for creating APIs and microservices. An important feature is its cross-platform nature, which allows applications to run on different operating systems without the need for code changes. Thus, Node.js is becoming an increasingly popular choice for developers looking to create fast and efficient web solutions.

The benefits of using Node.js for application development are obvious: it provides high performance thanks to its non-blocking architecture, and also allows you to create scalable networked applications. In addition, Node.js supports the huge npm ecosystem package, which makes it easy to integrate various libraries and tools. Installing from repositories ensures that you get a verified version of Node.js, which is important to ensure the security and stability of your application.

Methods for installing Node.js on Ubuntu and Debian

Installing Node.js on Ubuntu and Debian operating systems can be done in several ways, each with its own advantages. One of the easiest methods is to use the APT package manager. However, to get the latest version, it is recommended to install Node.js through the Node Version Manager (NVM). The installation method you choose depends on your needs and preferences, but each method will ensure that Node.js runs reliably on Ubuntu and Debian.

Option 1: Install Node.js from repositories

Installing Node.js from repositories is one of the easiest and fastest ways to start developing applications using this powerful platform. For most operating systems, such as Ubuntu or Debian, official repositories are available that contain the latest stable versions of Node.js. To install Node.js, all you need to do is open a terminal and enter a few commands. By following the simple steps, you will be able to quickly set up a working development environment that will significantly speed up the process of creating applications and reduce the possibility of errors.

To install Node.js on Debian and Ubuntu operating systems, we use the apt package manager. First, let's update the package list:
apt updateAnd let's install Node.js itself with a simple command:
apt install nodejs
You can check the version of the installed version with command:
nodejs -vThe conclusion would be roughly as follows:
v18.19.0

In case the installed version of Node.js meets your requirements, you will only need to install the Node.js Package Manager, which will allow you to manage modules and packages for Node.js. This will require installing the npm package using apt:
apt install npm

Option 2. Installing Node.js from NodeSource

For installing Node.js on Debian and Ubuntu systems, one of the most reliable methods is to use NodeSource repositories. This method provides access to up-to-date versions of Node.js and simplifies the installation process. To get started, open a terminal and run the command to add a NodeSource repository. For example, to install version 22.x, type:
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
2025-01-26 16:27:48 - Repository configured successfully.
2025-01-26 16:27:48 - To install Node.js, run: apt-get install nodejs -y
2025-01-26 16:27:48 - You can use N|solid Runtime as a node.js alternative
2025-01-26 16:27:48 - To install N|solid Runtime, run: apt-get install nsolid -y

For information on available versions for a particular OS version, see the NodeSource documentation.

You can then install Node.js, or upgrade an existing installed version, with the command:
apt install nodejs
Make sure you have the necessary system packages installed, such as build-essential, which may be needed to compile some dependencies. You can verify the success of the installation by using the command that will print the installed version of Node.js:
nodejs -vor
node -v
v22.13.1

It is not necessary to install the npm package separately, as in the first installation option.

Using NodeSource ensures that you receive security updates and patches, which is especially important for web application development. Thus, installing Node.js from NodeSource is the best choice for developers working on Debian and Ubuntu, providing a stable and up-to-date development environment.

Option 3. Installing Node.js using Node Version Manager

Installing Node.js using Node Version Manager (NVM) is one of the most convenient ways to manage Node.js versions on Debian. NVM makes it easy to install, upgrade and switch between different versions of Node.js, which is especially useful for developers working on multiple projects with different requirements. To get started, you first need to install NVM. This can be done by running the install command in the terminal, which will download and run the install script:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc

After successfully installing NVM, you will be able to check the available versions of Node.js using the command:
nvm ls-remote
To install a particular version, just type: `nvm install `, for example:
nvm install 16.13.0
After that, you can activate the installed version with:
nvm use 18.16.0
And to select the system version, if one is installed:
nvm use system
NVM also allows you to install default versions of Node.js with a single command, which makes things easier:
nvm alias default 16.13.0
You can uninstall a previously installed version of Node.js with the command:
nvm uninstall 16.13.0
You can view the list of installed versions in the system with the command:
nvm lsor
nvm list
      v16.13.0
      v16.20.2
      v18.16.0
->    v20.18.2
        system
default -> 16.13.0 (-> v16.13.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v20.18.2) (default)
stable -> 20.18 (-> v20.18.2) (default)
lts/* -> lts/jod (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2
lts/hydrogen -> v18.20.6 (-> N/A)
lts/iron -> v20.18.2
lts/jod -> v22.13.1 (-> N/A)
The selected version is marked with an arrow in the output. Not only Node.js versions are displayed, but also their aliases, which can be used to install the desired version:
nvm install lts/jod
Using NVM not only simplifies Node.js version control, but also makes your workflow more flexible and user-friendly, which is an important aspect of development on the Debian platform.
26 Jan 2025, 18:03:01

VPS in Bulgaria

Browse Configurations

Premium dedicated servers

Browse Configurations