How to Install Node.js on Debian 10
Installing Node.js from the debian repositories
Run the following command list the modules that provide the nodejs package
apt update
apt install nodejs npm
Output:
root@vps:~# apt install nodejs npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
binutils binutils-common binutils-x86-64-linux-gnu build-essential cpp cpp-8
Check the version Once the installation is complete
nodejs --version
Output:
root@vps:~# nodejs --version
v10.15.2
Installing Development Tools
It's necessary for compiling and installing native add-ons from the npm registry
apt install build-essential
Output:
root@vps:~# apt install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version (12.6).
0 upgraded, 0 newly installed, 0 to remove and 49 not upgraded.
Uninstalling Node.js
If you wish to uninstall Nodejs and npm packages, you can run the command
apt remove nodejs npm
Output:
root@vps:~# apt remove nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
gyp javascript-common libc-ares2 libjs-inherits libjs-is-typedarray libnode-dev libnode64 libssl-dev libuv1 libuv1-dev nodejs-doc python-pkg-resources
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
To verify that nodejs is uninstalled you can run the following command
nodejs --version
Output:
[root@vps ~]# nodejs --version
-bash: /usr/bin/nodejs: No such file or directory
[root@vps ~]#