I find that many apps use different versions of Electron, and I'm left with residual Electron versions no longer used.
sudo pacman -Qqtd | grep electron | sudo pacman -Rs -
Sometimes this is useful for removing a source-build package and replacing it with a prebuilt binary package, e.g. for Qt libraries.
Caution this is hazardous. You should directly review all packages before removing them, to ensure you're not removing critical dependencies.
Review all packages who were once installed as dependencies but no longer required by another package.
sudo pacman -Qqtd | less
Before removing all orphaned packages (below), do check that you're not removing a critical build dependency (e.g. cmake) that will prevent you from building and installing packages you need.
sudo pacman -Qqtd | sudo pacman -Rs -
You can determine which other packages would be affected by removal of a package as well.
for i in electron electron31 electron27 ; do sudo pacman -Sii ${i} ; done | less
Perhaps easier is to find only the impacted packages from a set:
sudo pacman -Qqtd | grep electron | sudo pacman -Sii - | grep "Required By"
Find all packages on the system who have some missing dependencies.
sudo pacman -Qq | sudo xargs -L 1 pacman -T | less
You can resolve their dependencies by reinstalling the affected packages.
You may be retaining several gigabytes of older package versions in your local cache. Sometimes cleaning that is helpful.
sudo pacman -Sc
Pacman will also clean the cache automatically after every upgrade if you want...
sudo pacman -Syuc
Ideally you'd remove backages you no longer need, and let Pacman prune orphaned packages at the same time, as well as all packages that depend on whatever you specifically removed.
Caution is warranted, as you'd best review the removed packages to avoid removing something you needed by accident.
sudo pacman -Rcsu _packagename_