We will discuss installing Node from the default Debian repository
Installing the Official Debian Node.js Package
Debian contains a version of Node.js in its default repositories. At the time of writing, this version is 10.15.2, which will reach end-of-life on April 1, 2021. At this date it will no longer be supported with security and bug fixes. If you would like to experiment with Node using an easy-to-install, stable, and long-term option, then installing from the Debian repo may make sense.
To get Node.js from the default Debian software repository, you can use the
apt package manager. First, refresh your local package index:
$ sudo apt update
Then install the Node.js package, and
npm the Node Package Manager:
$ sudo apt install nodejs npm
To verify that the install was successful, run the
node command with the
-v flag to get the version:
itadmin@dev:/ $ node -v v10.21.0
$ npm -v
itadmin@dev:/ $ npm -v 5.8.0
You can uninstall Node.js using
nvm, depending on the version you want to target. To remove versions installed from the Debian repository or from the PPA, you will need to work with the
apt utility at the system level.
To remove either of these versions, type the following:
$ sudo apt remove nodejs
This command will remove the package and the configuration files.