E:无法纠正问题,你已经破了包裹

我使用的是几天前安装的Ubuntu 13.04。 我正在尝试安装nodejsnpm 。 我尝试先从命令行安装然后卸载它。 然后事情就破了。

 sudo apt-get install -f nodejs npm Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: nodejs : Conflicts: npm E: Unable to correct problems, you have held broken packages. 

/etc/apt/sources.list的输出如下:

 # deb cdrom:[Ubuntu 13.04 _Raring Ringtail_ - Release amd64 (20130424)]/ raring main restricted # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. deb http://in.archive.ubuntu.com/ubuntu/ raring main restricted deb-src http://in.archive.ubuntu.com/ubuntu/ raring main restricted ## Major bug fix updates produced after the final release of the ## distribution. deb http://in.archive.ubuntu.com/ubuntu/ raring-updates main restricted deb-src http://in.archive.ubuntu.com/ubuntu/ raring-updates main restricted ## NB software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team. Also, please note that software in universe WILL NOT receive any ## review or updates from the Ubuntu security team. deb http://in.archive.ubuntu.com/ubuntu/ raring universe deb-src http://in.archive.ubuntu.com/ubuntu/ raring universe deb http://in.archive.ubuntu.com/ubuntu/ raring-updates universe deb-src http://in.archive.ubuntu.com/ubuntu/ raring-updates universe ## NB software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team, and may not be under a free licence. Please satisfy yourself as to ## your rights to use the software. Also, please note that software in ## multiverse WILL NOT receive any review or updates from the Ubuntu ## security team. deb http://in.archive.ubuntu.com/ubuntu/ raring multiverse deb-src http://in.archive.ubuntu.com/ubuntu/ raring multiverse deb http://in.archive.ubuntu.com/ubuntu/ raring-updates multiverse deb-src http://in.archive.ubuntu.com/ubuntu/ raring-updates multiverse ## NB software from this repository may not have been tested as ## extensively as that contained in the main release, although it includes ## newer versions of some applications which may provide useful features. ## Also, please note that software in backports WILL NOT receive any review ## or updates from the Ubuntu security team. deb http://in.archive.ubuntu.com/ubuntu/ raring-backports main restricted universe multiverse deb-src http://in.archive.ubuntu.com/ubuntu/ raring-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu raring-security main restricted deb-src http://security.ubuntu.com/ubuntu raring-security main restricted deb http://security.ubuntu.com/ubuntu raring-security universe deb-src http://security.ubuntu.com/ubuntu raring-security universe deb http://security.ubuntu.com/ubuntu raring-security multiverse deb-src http://security.ubuntu.com/ubuntu raring-security multiverse ## Uncomment the following two lines to add software from Canonical's ## 'partner' repository. ## This software is not part of Ubuntu, but is offered by Canonical and the ## respective vendors as a service to Ubuntu users. # deb http://archive.canonical.com/ubuntu raring partner # deb-src http://archive.canonical.com/ubuntu raring partner ## This software is not part of Ubuntu, but is offered by third-party ## developers who want to ship their latest software. deb http://extras.ubuntu.com/ubuntu raring main deb-src http://extras.ubuntu.com/ubuntu raring main 

/etc/apt/sources.list.d/*的输出如下:

 deb http://ppa.launchpad.net/chris-lea/node.js/ubuntu raring main # deb-src http://ppa.launchpad.net/chris-lea/node.js/ubuntu raring main ### THIS FILE IS AUTOMATICALLY CONFIGURED ### # You may comment out this entry, but any other modifications may be lost. deb http://dl.google.com/linux/chrome/deb/ stable main ### THIS FILE IS AUTOMATICALLY CONFIGURED ### # You may comment out this entry, but any other modifications may be lost. deb http://dl.google.com/linux/chrome/deb/ stable main ### THIS FILE IS AUTOMATICALLY CONFIGURED ### # You may comment out this entry, but any other modifications may be lost. deb http://dl.google.com/linux/chrome/deb/ stable main deb http://deb.opera.com/opera/ stable non-free deb http://deb.opera.com/opera/ stable non-free deb http://deb.opera.com/opera/ stable non-free deb http://deb.opera.com/opera/ stable non-free 

您应该能够通过以下方式查看保留包的列表:

 apt-mark showhold 

然后取消他们

 sudo apt-mark unhold  

之后,您应该能够删除冲突的包(似乎是npm ),然后重新安装所有。

如果失败了, 你可以尝试aptitude方式 – 通常它能够更好地解开依赖树。

在这两种情况下,在应用命令时要小心,并仔细检查标记为要删除的包列表。

使用aptitude而不是apt-get。 它更聪明。 它不仅会为您处理降级冲突的软件包,还会提出一系列建议,询问您想要的许多可能建议的工作方案。

 sudo aptitude install myNewPackage 

如果你的机器上还没有aptitude,那就搞定吧

 sudo apt-get install aptitude 

为了解决这个问题,我只需要先使用下面的命令安装synaptic,然后一切正常。

 sudo apt-get install synaptic 

我发现dpkg -r允许我逐个删除包,而不会触发其他一系列行为。

我不确定这是一个很好的解决方案,但我接受它,一切似乎都很好。