Install Node.js in Debian 10
To be able to develop with Node.js or to deploy Node.js application on a server there has to be a Node.js runtime installed on the server. Whereas there is Node.js available in the Debian package repository its not the most current Node.js version. Let’s install Node.js in a more current version from a external apt repository.
For this we’ll use the apt repostory from Nodesource which is also recommended by ndoejs.org itself.
In this case we’ll install Node.js in the version 12. But the installation for Node.js versions 10/14/15 (current and LTS-Version) is quite similar.
Prerequisite
- a Linux system running Debian 10.
Install Node.js version 12
- Add Nodesource apt repository to the system (as root or using sudo):
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
The command above will also add the necessary repository keys and update the apt cache:
## Installing the NodeSource Node.js 12.x repo...
## Populating apt-get cache...
+ apt-get update
.....
Fetched 1,941 kB in 1s (1,622 kB/s)
Reading package lists... Done
## Confirming "buster" is supported...
+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_12.x/dists/buster/Release'
## Adding the NodeSource signing key to your keyring...
+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
OK
## Creating apt sources list file for the NodeSource Node.js 12.x repo...
+ echo 'deb https://deb.nodesource.com/node_12.x buster main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src https://deb.nodesource.com/node_12.x buster main' >> /etc/apt/sources.list.d/nodesource.list
## Running `apt-get update` for you...
+ apt-get update
.....
Get:8 https://deb.nodesource.com/node_12.x buster InRelease [4,584 B]
Get:9 https://deb.nodesource.com/node_12.x buster/main amd64 Packages [767 B]
Fetched 5,351 B in 1s (4,983 B/s)
Reading package lists... Done
## Run `sudo apt-get install -y nodejs` to install Node.js 12.x and npm
## You may also need development tools to build native addons:
sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
- After adding the Nodesource repository, install the Node.js. The npm package manager will be installed at the same time:
sudo apt-get install nodejs
- The newly installed Node.js interpretar can be called:
root@foo:~# nodejs --version
v12.20.1
root@foo:~# npm --version
6.14.10
Conclusion
In this article we’ve installed Node.js 12 in Debian Linux 10 which provides the needed runtime to execute Node.js applications.
↑ back to top ↑