Install Nodejs on Debian 11

|
Last Updated:
|
|

In this tutorial, you will learn how to install Nodejs on Debian 11. Nodejs is a JavaScript runtime built on Chrome’s V8 JavaScript engine and is designed to build scalable network applications.

Installing Nodejs on Debian

Nodejs is available on the default Debian 11 main repos. However, the available versions may not be up-to-date.

For example, in the command output below, you can see that Nodejs 12.x is available.

apt-cache policy nodejs
nodejs:
  Installed: (none)
  Candidate: 12.22.5~dfsg-2~11u1
  Version table:
     12.22.5~dfsg-2~11u1 500
        500 http://security.debian.org/debian-security bullseye-security/main amd64 Packages
     12.21.0~dfsg-5 500
        500 http://deb.debian.org/debian bullseye/main amd64 Packages

Install Nodejs APT Repository

Therefore, to install the latest, which is Nodejs 16.x, which is the current stable release as per the Nodejs releases page, you need to install Nodejs Deb repository on Debian 11 by executing the command below;

curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -

Install Nodejs

Once the repos are in place, you can now install Nodejs.

apt install nodejs

Get the information about installed version of Nodejs on Debian 11;

apt info nodejs
Package: nodejs
Version: 16.8.0-deb-1nodesource1
Priority: optional
Section: web
Maintainer: Ivan Iguaran <[email protected]>
Installed-Size: 122 MB
Provides: nodejs-dev, nodejs-legacy, npm
Depends: libc6 (>= 2.17), libgcc1 (>= 1:3.4), libstdc++6 (>= 4.8), python3-minimal, ca-certificates
Conflicts: nodejs-dev, nodejs-legacy, npm
Replaces: nodejs-dev (<= 0.8.22), nodejs-legacy, npm (<= 1.2.14)
Homepage: https://nodejs.org
Download-Size: 26.1 MB
APT-Manual-Installed: yes
APT-Sources: https://deb.nodesource.com/node_16.x bullseye/main amd64 Packages

You can also check installed version of Nodejs on Debian 11;

node -v
v16.8.0

Note that the command above also installs NPM along with Nodejs. You can verify by checking the version of installed NPM on Debian 11.

npm -v
7.21.0

Install development tools to build native addons

If you need to build native Nodejs addons, you need to install some development tools by running the command below;

apt install gcc g++ make

Install Yarn on Debian 11

You may also want to install Yarn on Debian 11. To do so, run the command below:

curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
apt update
apt install yarn

You can now proceed to build your web applications using Nodejs.

Read more on Nodejs getting started guide.

Other tutorials

Install Yarn on Debian 11

Install PHP Composer on Debian 11

Install PHP 8.0 on Debian 11

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
gen_too
Co-founder of Kifarunix.com, Linux Tips and Tutorials. Linux/Unix admin and author at Kifarunix.com.

Leave a Comment