How To Install Node.js on Debian 12: A Quick Guide

Do you want to know how to install Node.js on Debian 12? You are at the right place!

Node.js is a cross-platform, open-source JavaScript runtime environment that executes JS code outside of a web browser. It’s a popular tool among developers to create scalable network applications due to its asynchronous, event-driven architecture.

Installing it on Debian 12 can provide a stable and efficient environment for server-side and networking applications.

In this blog, we will discuss all possible methods to install Node.js on Debian 12.

So, let’s bring it on!

How To Install Node.js on Debian 12

Follow the below methods to install Node.js on Debian 12:

1. Installing Node.js Using Debian’s Default Repository

The easiest way to install Node.js is by using the default Debian repository. It is simple but does not provide the most recent version of Node.js.

To install Node.js, run the following command:

sudo apt install nodejs npm -y
 InstallNode.js npm on Debian-12

After installation, you can verify the installed versions with:

node --version && npm --version
Verify Node.js installation on Debian 12

2. Installing Node.js Using Node.js Deb Repository

For those who need the latest version of Node.js, the NodeSource repository is an excellent alternative. NodeSource provides a script that automatically adds the repository to your system and installs Node.js:

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -
Download .deb repository of Node.js

Next, install Node.js using:

sudo apt install nodejs -y
Install Node.js on Debian 12

Finally, verify the installation with the below command:

node --version
Verify Node.js installation on Debian 12

3. Installing Node.js Using Node Version Manager (NVM)

NVM is a version manager for Node.js that allows you to install and manage multiple versions of Node.js. To install NVM and Node.js, use the following commands:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
install node version manager

After that, add the NVM script in the path and install node via the nvm:

source ~/.bashrc
nvm install node
Install Node.js on Debian 12

Note: To install a specific version, such as the latest Long-Term Support (LTS) version, you can use “nvm install –lts“. However, you can use “nvm ls” to list installed Node.js versions.

4. Installing Node.js on Debian 12 Using Snap

You can also use the snap package manager to install Node.js with the below command:

sudo snap install node --channel=22/stable --classic
Install node .js on debian 12 from snap

Conclusion

In this guide, we have demonstrated how to install Node.js on Debian 12. The simplest way is to use the default repository by running the “sudo apt install nodejs npm -y” command. Alternatively, you can install Node.js using the Node Source Repository or the Node Version Manager (NVM). They allow for managing multiple Node.js versions.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Scroll to Top