Ubuntu 如何解决以下包具有未满足的依赖关系`

Ubuntu 如何解决以下包具有未满足的依赖关系`,ubuntu,npm,Ubuntu,Npm,我用这个脚本安装基本软件,但由于网速太慢,不得不中断。 现在,当我点击$sudo apt get install npm时,出现以下错误 yask123@yaskslaptop:~$ sudo apt-get installed npm E: Invalid operation installed yask123@yaskslaptop:~$ sudo apt-get install npm Reading package lists... Done Building dependency tr

我用这个脚本安装基本软件,但由于网速太慢,不得不中断。 现在,当我点击
$sudo apt get install npm
时,出现以下错误

yask123@yaskslaptop:~$ sudo apt-get installed npm
E: Invalid operation installed
yask123@yaskslaptop:~$ sudo apt-get install 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:
 npm : Depends: nodejs but it is not going to be installed
       Depends: node-abbrev (>= 1.0.4) but it is not going to be installed
       Depends: node-ansi (>= 0.3.0-2) but it is not going to be installed
       Depends: node-ansi-color-table but it is not going to be installed
       Depends: node-archy but it is not going to be installed
       Depends: node-block-stream but it is not going to be installed
       Depends: node-fstream (>= 0.1.22) but it is not going to be installed
       Depends: node-fstream-ignore but it is not going to be installed
       Depends: node-github-url-from-git but it is not going to be installed
       Depends: node-glob (>= 3.1.21) but it is not going to be installed
       Depends: node-graceful-fs (>= 2.0.0) but it is not going to be installed
       Depends: node-inherits but it is not going to be installed
       Depends: node-ini (>= 1.1.0) but it is not going to be installed
       Depends: node-lockfile but it is not going to be installed
       Depends: node-lru-cache (>= 2.3.0) but it is not going to be installed
       Depends: node-minimatch (>= 0.2.11) but it is not going to be installed
       Depends: node-mkdirp (>= 0.3.3) but it is not going to be installed
       Depends: node-gyp (>= 0.10.9) but it is not going to be installed
       Depends: node-nopt (>= 3.0.1) but it is not going to be installed
       Depends: node-npmlog but it is not going to be installed
       Depends: node-once but it is not going to be installed
       Depends: node-osenv but it is not going to be installed
       Depends: node-read but it is not going to be installed
       Depends: node-read-package-json (>= 1.1.0) but it is not going to be installed
       Depends: node-request (>= 2.25.0) but it is not going to be installed
       Depends: node-retry but it is not going to be installed
       Depends: node-rimraf (>= 2.2.2) but it is not going to be installed
       Depends: node-semver (>= 2.1.0) but it is not going to be installed
       Depends: node-sha but it is not going to be installed
       Depends: node-slide but it is not going to be installed
       Depends: node-tar (>= 0.1.18) but it is not going to be installed
       Depends: node-underscore but it is not going to be installed
       Depends: node-which but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

让Ubuntu修复未满足的依赖项和损坏的包的命令是

sudo apt-get install -f
从手册页:

-f、 --修理坏的 修理尝试更正存在已断开的依赖关系的系统。 此选项与install/remove一起使用时,可以省略任何软件包 允许APT推断可能的解决方案。如果包是 如果指定,则必须完全纠正问题。选择权 当第一次运行APT时,有时是必要的;恰当的 它本身不允许断开的包依赖关系存在于 系统。系统的依赖结构可能是 腐败到需要人工干预(通常意味着 使用dselect(1)或dpkg--删除以消除某些 违规软件包)

运行命令时,Ubuntu将尝试修复自身。完成后,您可以通过再次运行该命令来测试它是否工作,并且您将收到类似以下内容的输出:

正在阅读软件包列表。。。多恩 构建依赖树 正在读取状态信息。。。多恩 0已升级,0已新安装,0已删除,2未升级


Node附带安装了npm,因此您应该有一个npm版本。但是,npm的更新频率比Node高,所以您需要确保它是最新版本

试一试


如果
sudo apt get install-f
不起作用,请尝试aptitude

sudo apt-get install aptitude
sudo aptitude install <package-name>
所以我尝试了性向,结果我不得不降低一些软件包的等级


安装nodejs将安装npm。。。因此,只需删除NodeJ,然后重新安装即可: $sudo apt获取删除节点

$ sudo apt-get --purge remove nodejs node npm
$ sudo apt-get clean
$ sudo apt-get autoclean
$ sudo apt-get -f install
$ sudo apt-get autoremove
首先,试试这个

sudo apt-get update
sudo apt-get clean
sudo apt-get autoremove
如果错误仍然存在,则执行此操作

sudo apt --fix-broken install
sudo apt-get update && sudo apt-get upgrade
sudo dpkg --configure -a
sudo apt-get install -f
然后再试一次:

sudo apt-get install npm
但是如果它仍然无法解决问题,请使用
sudodpkg--configure-a
检查依赖项,然后逐个删除它们。假设依赖关系依赖于npm,那么就这样吧

sudo apt-get remove nodejs
sudo apt-get remove npm
然后转到/etc/apt/sources.list.d并删除所有节点列表(如果有的话)。然后做一个测试

sudo apt-get update
然后使用
sudodpkg--configure-a
再次检查依赖项问题,如果全部清除,则完成。 稍后,使用以下命令再次安装npm

v=8   # set to 4, 5, 6, ... as needed
curl -sL https://deb.nodesource.com/setup_$v.x | sudo -E bash -
然后安装Node.js包

sudo apt-get install -y nodejs

上述答案也适用于一般情况(对于django等其他软件包的依赖关系),仅在前两个进程对您面临依赖关系的软件包使用相同的进程之后。

我是在最新稳定版本中安装node js时遇到这种情况的

curl-sLhttps://deb.nodesource.com/setup_10.x |sudo-E bash-

看起来这个版本已经有了一个预打包的NPM。所以当我再次尝试安装NPM时,我遇到了这个错误。如果有人以这种方式安装Nodejs,那么就不需要单独安装NPM

The following packages have unmet dependencies:
 npm : Depends: nodejs but it is not going to be installed
       Depends: node-abbrev (>= 1.0.4) but it is not going to be installed
       Depends: node-ansi (>= 0.3.0-2) but it is not going to be installed
       Depends: node-ansi-color-table but it is not going to be installed
       Depends: node-archy but it is not going to be installed
       Depends: node-block-stream but it is not going to be installed
       Depends: node-fstream (>= 0.1.22) but it is not going to be installed
       Depends: node-fstream-ignore but it is not going to be installed
       Depends: node-github-url-from-git but it is not going to be installed
       Depends: node-glob (>= 3.1.21) but it is not going to be installed
       Depends: node-graceful-fs (>= 2.0.0) but it is not going to be installed
       Depends: node-inherits but it is not going to be installed
       Depends: node-ini (>= 1.1.0) but it is not going to be installed
       Depends: node-lockfile but it is not going to be installed
       Depends: node-lru-cache (>= 2.3.0) but it is not going to be installed
       Depends: node-minimatch (>= 0.2.11) but it is not going to be installed
       Depends: node-mkdirp (>= 0.3.3) but it is not going to be installed
       Depends: node-gyp (>= 0.10.9) but it is not going to be installed
       Depends: node-nopt (>= 3.0.1) but it is not going to be installed
       Depends: node-npmlog but it is not going to be installed
       Depends: node-once but it is not going to be installed
       Depends: node-osenv but it is not going to be installed
       Depends: node-read but it is not going to be installed
       Depends: node-read-package-json (>= 1.1.0) but it is not going to be installed
       Depends: node-request (>= 2.25.0) but it is not going to be installed
       Depends: node-retry but it is not going to be installed
       Depends: node-rimraf (>= 2.2.2) but it is not going to be installed
       Depends: node-semver (>= 2.1.0) but it is not going to be installed
       Depends: node-sha but it is not going to be installed
       Depends: node-slide but it is not going to be installed
       Depends: node-tar (>= 0.1.18) but it is not going to be installed
       Depends: node-underscore but it is not going to be installed
       Depends: node-which but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

我刚刚解决了这个问题。 问题在于版本冲突。 Nodejs 10与npm一起安装。 因此,在安装nodejs之前,请删除旧的npm。 或者删除新节点->删除npm->再次安装节点

这是唯一帮助我的方法

sudo apt install aptitude
然后


来源:

这是npm包中关于依赖关系的一个错误:

已经报告了错误。 以上可能不起作用,这取决于你已经安装了什么,至少在最新的Ubuntu18.04 LTS上没有

我按照建议的依赖项进行了操作,并按照上面的链接进行了安装:

sudo apt-get install nodejs-dev node-gyp libssl1.0-dev
然后

sudo apt-get install npm
如果您受到影响,请订阅该错误:

bugs.launchpad.net/ubuntu/+source/npm/+bug/1517491

bugs.launchpad.net/ubuntu/+source/npm/+bug/1809828

我尝试了很多方法,但下面的方法非常有效

执行此命令后,运行以下命令:-

curl -sL https://deb.nodesource.com/setup_14.x 565 | sudo -E bash -
sudo apt-get install -y nodejs
现在检查一下

node -v
npm -v
首先,跑步

sudo apt-get install nodejs-dev node-gyp libssl1.0-dev
然后跑

sudo apt install npm

对我来说,解决这个问题的办法是:

$ apt update
$ apt install nodejs

我从官方Debian存储库安装了
nodejs
。这是通过
无人值守升级安装的。在此之前,它是从安装。来自NodeSource的一个在
nodejs
包中有
npm

在主题之外,我想这是因为nodejs是从deb.NodeSource.com安装的,而npm是从ubuntu安装的。通常混合源应该是可以的,但是由于某些原因,nodesource版本没有被标记为满足npm依赖性。您可以通过比较
apt cache policy npm
apt cache policy nodejs
来了解这一点。天分的答案对我来说很有用,但把天分和天分混为一谈让我很紧张。@Quantum7的评论一定是答案!我有理由投赞成票。它帮助我找出了问题所在。删除
deb.nodesource.com
解决了这个错误。在最初的解决方案基础上,我们尝试了一些解决方案,但最终实现了。很好的提示!!aptitude可能会损坏整个系统,如果您使用不够小心,将apt和aptitude一起使用可能会删除所有软件包!我有一个非常混乱的依赖问题。使用apt get尝试了许多命令,包括-f install,但没有成功。简单的“sudo aptitude安装”完全解决了这个问题。当被问及“接受此解决方案[Y/n/q/?]”时,请输入“.”以获得下一个解决方案。我在安装许多软件包时也遇到了同样的问题。这个解决方案有效。对于所有“将以下软件包保持在其当前版本?”的问题,请说“否”。对于所有“降级以下软件包”,在我的情况下说“是”,sudo apt get-f remove
删除了损坏的软件包。工作:E:Sub-process/usr/bin/dpkg返回了一个错误代码(1)非常感谢您为我提供的所有这些答案。对于我来说,我得到的答案是:E:Package'libssl1.0-dev'没有错误
node -v
npm -v
sudo apt-get install nodejs-dev node-gyp libssl1.0-dev
sudo apt install npm
$ apt update
$ apt install nodejs