web-dev-qa-db-ja.com

「次のパッケージには依存関係が満たされていない」を解決する方法

このスクリプトを使用して基本的なソフトウェアをインストールしていましたが、インターネット速度が遅いため中断する必要がありました。 $ 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.
44
yask

Ubuntuに満たされていない依存関係と壊れたパッケージを修正させるコマンドは

Sudo apt-get install -f

manページから:

-f、-fix-broken修正;破損した依存関係が存在するシステムを修正しようとします。このオプションをinstall/removeとともに使用すると、パッケージを省略してAPTが解決策を推測できるようにすることができます。パッケージが指定されている場合、これらは問題を完全に修正する必要があります。このオプションは、APTを初めて実行するときに必要になる場合があります。 APT自体は、壊れたパッケージの依存関係がシステムに存在することを許可しません。システムの依存関係構造が壊れて手動の介入が必要になる可能性があります(通常、問題のあるパッケージを削除するためにdselect(1)またはdpkg --removeを使用することを意味します)

Ubuntuは、コマンドを実行すると自動的に修正を試みます。完了したら、コマンドを再度実行することで機能するかどうかをテストできます。次のような出力が表示されます。

パッケージリストの読み取り中...完了依存関係ツリーの構築状態情報の読み取り中...完了0アップグレード済み、0新しくインストール済み、0で削除、2でアップグレードなし。

23
Eric Stillwagon

Sudo apt-get install -f <package-name>が機能しない場合は、aptitudeを試してください。

Sudo apt-get install aptitude
Sudo aptitude install <package-name>

Aptitudeは問題の解決を試みます。

例として、私の場合、libcurl4-openssl-devをインストールしようとするとエラーが発生します:

Sudo apt-get install -f libcurl4-openssl-dev

だから私はaptitudeを試して、いくつかのパッケージをダウングレードする必要があることがわかりました。

The following actions will resolve these dependencies:

    Keep the following packages at their current version:
    1)     libyaml-dev [Not Installed]                        

Accept this solution? [Y/n/q/? (n)

The following actions will resolve these dependencies:

    Downgrade the following packages:                                
    1)     libyaml-0-2 [0.1.4-3ubuntu3.1 (now) -> 0.1.4-3ubuntu3 (trusty)]

Accept this solution? [Y/n/q/?] (Y)
62
Tapa

まずはこれを試してください

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

それでも問題を解決できない場合は、Sudo dpkg --configure -aを使用して依存関係を確認し、それらを1つずつ削除してください。依存関係がnpmにあり、これに進むとしましょう。

Sudo apt-get remove nodejs
Sudo apt-get remove npm

次に、/ etc/apt/sources.list.dに移動し、ノードリストがある場合は削除します。それから

Sudo apt-get update

次に、Sudo dpkg --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などのような他のパッケージへの依存関係の場合)最初の2つのプロセスが依存関係に直面しているパッケージに対して同じプロセスを使用した直後 =

16
Akash Kandpal

Nodejsをインストールするとnpmがインストールされるので、nodejsを削除してから再インストールします。$ Sudo apt-get remove nodejs

$ 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
12
Russo

最新の安定版リリースからノードjsをインストールしたときにこの状況になりました。

curl -sL https://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.

1

この問題を解決しました。問題はバージョンの競合にありました。 npmでインストールされたNodejs 10。したがって、nodejsをインストールする前に、古いnpmを削除してください。または、新しいノードを削除-> npmを削除->ノードを再度インストールします。

これは私を助けた唯一の方法です。

0