How to Install Node.js on Debian 8

While it is possible to install Node.js with the Advanced Packaging Tool (apt-get), or even with NVM, it is not recommended because they lag behind in versioning, and because those packages do some funky things with the naming conventions. Instead, it's much better to install it manually.

Step 1: Download Node.js

First, navigate to the official Node.js website and download the latest LTS version for Linux.

wget https://nodejs.org/dist/v14.17.0/node-v14.17.0-linux-x64.tar.xz

Step 2: Extract the archive

Once downloaded, extract the archive:

tar -xf node-v14.17.0-linux-x64.tar.xz

Step 3: Move to /usr/local

Move the extracted folder to /usr/local:

sudo mv node-v14.17.0-linux-x64 /usr/local/node

Step 4: Set up environment variables

Add Node.js to your PATH by editing your .bashrc file:

echo 'export PATH=/usr/local/node/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

Step 5: Verify installation

Verify that Node.js is installed correctly:

node --version
npm --version

If you see version numbers displayed, congratulations! You've successfully installed Node.js on Debian 8.