Have you ever clicked "update" in your Node software, and then your Debian VPS is no longer working? It must be very stressful. Don't worry, you can fix that. I've done it before, and I will share here the step-by-step guide to fix a Debian VPS after Node Update Fails, it's easier than it seems.
Recovery mode is sort of like a safety net—it allows you to repair broken software safely.
sudo apt-get update
sudo apt-get install -f
sudo dpkg --configure -a
sudo apt-get remove nodejs
sudo apt-get purge nodejs
sudo apt-get install nodejs
This actually uninstalls Node completely as well as renewing the installation. You may feel it's extreme, but time will prove you right.
sudo systemctl restart your-app.service
sudo journalctl -u your-app.service -f
Check that all systems are running before finishing.
Figure Out What Went Wrong
The first thing to do is to see how bad the situation is. Connect to your VPS using console or your hosting provider's tools and ask the following:- Can I access the server and login?
- Are simply the node services failing or is the whole VPS broken?
- Are there any error messages?
Boot into Recovery Mode
Debian has recovery mode for incidents like this. You should be able to reboot the server and select advanced options → recovery mode in the GRUB menu. Recovery mode boots a small safe system that will allow you to fix things without crashing everything.Recovery mode is sort of like a safety net—it allows you to repair broken software safely.
Repair Broken Node Packages
Once you're in recovery mode, the first thing to try to fix is Node. Run:sudo apt-get update
sudo apt-get install -f
sudo dpkg --configure -a
- apt-get update will update the package list.
- install -f will repair broken dependencies.
- dpkg --configure -a will configure any packages that didn't finish installing.
Re-Install Node If Needed
If it's still not working, you might need a fresh install:sudo apt-get remove nodejs
sudo apt-get purge nodejs
sudo apt-get install nodejs
This actually uninstalls Node completely as well as renewing the installation. You may feel it's extreme, but time will prove you right.
Restart Your Apps
Once you have Node working again, restart your apps and check for errors;sudo systemctl restart your-app.service
sudo journalctl -u your-app.service -f
Check that all systems are running before finishing.