在 Ubuntu 22.04 LTS 上安装 NPM 时出现库错误

在 Ubuntu 22.04 LTS 上安装 NPM 时出现库错误

我正在尝试在 Ubuntu 22.04 LTS 上安装 NPM;

我该如何解决这个问题?

步骤1:

user@ubuntu:~$ sudo apt-get update              
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease                    
    Reading package lists... Done

user@ubuntu:~$ sudo apt update
Hit:1 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 https://repo.protonvpn.com/debian stable InRelease                  
Hit:3 http://archive.ubuntu.com/ubuntu jammy InRelease                    
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
atenreiro@stellar:~$ 

第2步:

user@ubuntu:~$ sudo apt-get install npm
Reading package lists... Done
Building dependency tree... Done
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:
 libssl-dev : Depends: libssl3 (= 3.0.2-0ubuntu1) but 3.0.2-0ubuntu1.6 is to be installed
E: Unable to correct problems, you have held broken packages.
user@ubuntu:~$ 

步骤3:

user@ubuntu:~$ sudo apt-get install libssl3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libssl3 is already the newest version (3.0.2-0ubuntu1.6).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
user@ubuntu:~$ 

步骤4:

user@ubuntu:~$ sudo apt show libssl-dev -a
Package: libssl-dev
Version: 3.0.2-0ubuntu1
Priority: optional
Section: libdevel
Source: openssl
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Debian OpenSSL Team <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 12.4 MB
Depends: libssl3 (= 3.0.2-0ubuntu1)
Suggests: libssl-doc
Conflicts: libssl1.0-dev
Homepage: https://www.openssl.org/
Download-Size: 2,372 kB
APT-Sources: http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
Description: Secure Sockets Layer toolkit - development files
 This package is part of the OpenSSL project's implementation of the SSL
 and TLS cryptographic protocols for secure communication over the
 Internet.
 .
 It contains development libraries, header files, and manpages for libssl
 and libcrypto.

user@ubuntu

步骤5:

user@ubuntu:~$ cat /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu jammy main universe restricted
user@ubuntu:~$

答案1

看起来您错过了更新频道。

当我运行时,apt show libssl-dev -a我得到了列出的两个版本的包:

Package: libssl-dev
Version: 3.0.2-0ubuntu1.6
Depends: libssl3 (= 3.0.2-0ubuntu1.6)
APT-Sources: http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages

Package: libssl-dev
Version: 3.0.2-0ubuntu1
Depends: libssl3 (= 3.0.2-0ubuntu1)
APT-Sources: http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages

(为简洁起见,输出减少到最低限度)

如您所见,您使用的软件包版本来自常规渠道,而所需的版本来自jammy-updates

将频道添加到您的sources.list

deb http://archive.ubuntu.com/ubuntu/ jammy-updates main universe restricted

当您这样做的时候,您可能还想添加jammy-security

deb http://security.ubuntu.com/ubuntu/ jammy-security main universe restricted

相关内容