How to delete broken packages in ubuntu

I can not remove broken package. Use the following command: sudo apt-get -f install but I get the following response:

Preparing to unpack .../nodejs_0.10.28-1chl1~trusty1_amd64.deb ...
Unpacking nodejs (0.10.28-1chl1~trusty1) over (0.10.25~dfsg2-2ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/nodejs_0.10.28-1chl1~trusty1_amd64.deb (--unpack):
 trying to overwrite '/usr/share/man/man1/node.1.gz', which is also in package nodejs-legacy 0.10.25~dfsg2-2ubuntu1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Processing triggers for man-db (2.6.7.1-1) ...
Errors were encountered while processing:
 /var/cache/apt/archives/nodejs_0.10.28-1chl1~trusty1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I tried various commands like

 2015  sudo apt-get clean
 2020  sudo dpkg --configure -a
 2023  sudo apt-get autoremove
 2034  sudo apt-get upgrade && sudo apt-get -f install

But I did not get any result. I can not install synaptic. Any ideas how can I remove the broken package ?


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.