How To Install Node.js on Debian 12
To install Node.js on Debian 12, you have two options. The first one usesapt
to install the nodejs
package from Debian’s default software repository. The second option involves using Node.js binary distributions provided by NodeSource, which allows you to install different and more recent stable versions of Node.js.
I will walk you through both options to install Node.js on your Debian server, and then you can choose whichever one you prefer.
Installing Node.js on Debian - Prerequisites
- Basic knowledge of the Linux command line.
- An Debian 12 server with a non-root user with
sudo
privileges. You can get affordable, and powerful Debian servers from our website, and you can check out our How to access your server using SSH guide to learn how to access your server and create asudo
user.
Updating the Package Cache and Installing Build Tools
Start by updating the packages in the package manager cache to the latest available versions using the following command:sudo apt update
Before you install Node.js, it is recommended that you install build tools to compile and install native add-ons from the Node.js package manager:
sudo apt install -y build-essential
Option 1: Installing Node.js on Debian From the Default Repositories
For the simplest way to install Node.js on Debian, you can useapt
to install the default Node.js version that is available in the default Debian repositories. However, note that this version is an LTS (long-term support) release, which is often outdated, although it has a long support period.
To install the nodejs
Continue reading this article
by subscribing to our newsletter.
Subscribe nowby subscribing to our newsletter.
A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.
If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.