在 ubuntu 上安装 npm 时出现损坏的软件包错误

在 ubuntu 上安装 npm 时出现损坏的软件包错误

我正在尝试在我的 Ubuntu 机器上安装 gtop。为此,我需要安装 nodejs 和 npm 包管理器。首先,我安装了 nodejs,sudo apt install nodejs安装得很好,但在安装 npm 时,我收到了这个依赖项错误消息:

The following packages have unmet dependencies:
libssl-dev : Depends: libssl1.1 (= 1.1.1j-1ubuntu3) but 1.1.1j-1ubuntu3.5 
is to be installed
libuv1-dev : Depends: libuv1 (= 1.40.0-1) but 1.40.0-1ubuntu0.1 is to be installed
E: Unable to correct problems, you have held broken packages.

我更新并升级了系统并重新安装了 nodejs,甚至进行了更新,--fix-missing但仍然存在同样的问题。

结果apt-cache policy libuv1

  libuv1:
  Installed: 1.40.0-1ubuntu0.1
  Candidate: 1.40.0-1ubuntu0.1
  Version table:
 *** 1.40.0-1ubuntu0.1 100
        100 /var/lib/dpkg/status
     1.40.0-1 500
        500 http://cz.archive.ubuntu.com/ubuntu hirsute/main amd64 Packages

我有以下存储库:

$ grep -r deb /etc/apt/sources.list /etc/apt/sources.list.d/.
/etc/apt/sources.list: # deb cdrom:[Ubuntu 21.04 _Hirsute Hippo_ - Release amd64 (20210420)]/ hirsute main restricted
/etc/apt/sources.list:deb http://repo.iut.ac.ir/repo/Ubuntu/ hirsute restricted
/etc/apt/sources.list:# deb-src http://ir.archive.ubuntu.com/ubuntu/ hirsute main restricted
/etc/apt/sources.list:# deb-src http://ir.archive.ubuntu.com/ubuntu/ hirsute-updates main restricted
/etc/apt/sources.list:deb http://repo.iut.ac.ir/repo/Ubuntu/ hirsute universe
/etc/apt/sources.list:# deb-src http://ir.archive.ubuntu.com/ubuntu/ hirsute universe
/etc/apt/sources.list:# deb-src http://ir.archive.ubuntu.com/ubuntu/ hirsute-updates universe
/etc/apt/sources.list:deb http://repo.iut.ac.ir/repo/Ubuntu/ hirsute multiverse
/etc/apt/sources.list:# deb-src http://ir.archive.ubuntu.com/ubuntu/ hirsute multiverse
/etc/apt/sources.list:# deb-src http://ir.archive.ubuntu.com/ubuntu/ hirsute-updates multiverse
/etc/apt/sources.list:# deb-src http://ir.archive.ubuntu.com/ubuntu/ hirsute-backports main restricted universe multiverse
/etc/apt/sources.list:# deb http://archive.canonical.com/ubuntu hirsute partner
/etc/apt/sources.list:# deb-src http://archive.canonical.com/ubuntu hirsute partner
/etc/apt/sources.list:deb http://repo.iut.ac.ir/repo/Ubuntu/ hirsute-security restricted
/etc/apt/sources.list:# deb-src http://security.ubuntu.com/ubuntu hirsute-security main restricted
/etc/apt/sources.list:deb http://repo.iut.ac.ir/repo/Ubuntu/ hirsute-security universe
/etc/apt/sources.list:# deb-src http://security.ubuntu.com/ubuntu hirsute-security universe
/etc/apt/sources.list:deb http://repo.iut.ac.ir/repo/Ubuntu/ hirsute-security multiverse
/etc/apt/sources.list:# deb-src http://security.ubuntu.com/ubuntu hirsute-security multiverse
/etc/apt/sources.list:# (e.g. netinst, live or single CD). The matching "deb cdrom"
/etc/apt/sources.list:deb http://cz.archive.ubuntu.com/ubuntu hirsute main
/etc/apt/sources.list.d/./vscode.list:deb [arch=amd64,arm64,armhf] http://packages.microsoft.com/repos/code stable main
/etc/apt/sources.list.d/./windscribe-repo.list.save:deb https://repo.windscribe.com/ubuntu bionic main
/etc/apt/sources.list.d/./windscribe-repo.list:deb https://repo.windscribe.com/ubuntu bionic main
/etc/apt/sources.list.d/./vscode.list.save:deb [arch=amd64,arm64,armhf] http://packages.microsoft.com/repos/code stable main

答案1

你的存储库缺少主要的多毛更新多毛的安全组件。首先使用以下命令添加它们

sudo add-apt-repository -r "deb http://repo.iut.ac.ir/repo/Ubuntu/ hirsute restricted"
sudo add-apt-repository -r "deb http://repo.iut.ac.ir/repo/Ubuntu/ hirsute universe"
sudo add-apt-repository -r "deb http://repo.iut.ac.ir/repo/Ubuntu/ hirsute multiverse"
sudo add-apt-repository -r "deb http://repo.iut.ac.ir/repo/Ubuntu/ hirsute-security restricted"
sudo add-apt-repository -r "deb http://repo.iut.ac.ir/repo/Ubuntu/ hirsute-security universe"
sudo add-apt-repository -r "deb http://repo.iut.ac.ir/repo/Ubuntu/ hirsute-security multiverse"

sudo add-apt-repository "deb http://cz.archive.ubuntu.com/ubuntu hirsute universe multiverse restricted"
sudo add-apt-repository "deb http://cz.archive.ubuntu.com/ubuntu hirsute-security main universe multiverse restricted"
sudo add-apt-repository "deb http://cz.archive.ubuntu.com/ubuntu hirsute-updates main universe multiverse restricted"

然后更新软件包列表并安装所有需要升级的新依赖项

sudo apt-get update
sudo apt-get dist-upgrade

然后重试。

相关内容