How to delete broken packages in ubuntu
run this command to remove broken packages in ubuntu.
sudo dpkg --remove --force-remove-reinstreq package_name
after removing package update your system with command
sudo apt-get update
restart system after successfully updation.
I've found that:
sudo dpkg --remove --force-remove-reinstreq <packagename>
Works best. If it gives you an error that it won't remove a package because it is depended on by another package, remove that other package as well. You'll have to repeat this step several times and then reinstall your deleted packages.
The force-remove-reinstreq
is THE "nuclear option" of deleting a package. It only fails if there is another package depending on the one you're about to delete -- Again, in that case, deleted the depending package too.
Open your terminal and use following command
sudo dpkg --purge nodejs-legacy
sudo apt-get install -f
It should solve your problem.