š§Installing the Latest Node.js, npm, & PM2 from NodeSource on Debianāļø
Easily Install the Newest Node.js, npm, & PM2 on Debian Using NodeSource

Driving SD-WAN Adoption in South Africa
Search for a command to run...
Easily Install the Newest Node.js, npm, & PM2 on Debian Using NodeSource

Driving SD-WAN Adoption in South Africa
No comments yet. Be the first to comment.
Enhancing Security and Compliance with ManageEngine ADAudit Plus

Why Pings Aren't Enough & NMS is Essential

What is SD-WAN (Software Defined Wide Area Networking)? | The Mechanics of this Groundbreaking New Network Technology

Embracing First Principles & the Scientific Method

Ever Wondered | "Is My Internet Really 99.9% Reliable?" š¤

If you're running Debian and need the latest version of Node.js, npm, and PM2, the best way is to use NodeSourceās setup script. NodeSource maintains up-to-date versions of Node.js, which are newer than what Debianās package manager provides.
Before installing anything, update your system and install prerequisites:
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl ca-certificates
curl: Used to fetch the NodeSource setup script.
ca-certificates: Ensures secure HTTPS connections.
Run the official setup script from NodeSource. You can choose the latest LTS (recommended) or current (cutting-edge) version.
bashCopyEditcurl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
setup_lts.x script automatically detects your Debian version and configures the correct repository.curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
Now, install Node.js:
sudo apt install -y nodejs
After installation, check the installed versions:
node -v
npm -v
Expected output (example):
20.10.0
10.2.1
(Your version may vary depending on the latest release.)
PM2 is a production process manager that helps keep your Node.js apps running in the background.
Install it globally using npm:
sudo npm install -g pm2
pm2 -v
Expected output:
5.3.0
To ensure that PM2 starts your apps automatically after a reboot, run:
pm2 startup systemd
This outputs a command similar to:
sudo env PATH=$PATH:/usr/bin pm2 startup systemd -u youruser --hp /home/youruser
Run the command as shown to enable PM2 at boot.
To test, create a simple Node.js server:
echo 'console.log("Hello from PM2!"); setInterval(() => console.log("Running..."), 5000);' > test.js
Run the script with PM2:
pm2 start test.js --name my-test-app
pm2 status
This starts test.js and keeps it running.
To ensure PM2 restarts all running apps after a reboot:
pm2 save
š You now have the latest Node.js, npm, and PM2 installed on Debian!
Node.js & npm from NodeSource
PM2 to manage Node.js applications
Auto-start and persistence after reboots
Now you can deploy and manage your Node.js apps easily! š