![无法修复错误“以下软件包具有未满足的依赖关系”](https://linux22.com/image/1073601/%E6%97%A0%E6%B3%95%E4%BF%AE%E5%A4%8D%E9%94%99%E8%AF%AF%E2%80%9C%E4%BB%A5%E4%B8%8B%E8%BD%AF%E4%BB%B6%E5%8C%85%E5%85%B7%E6%9C%89%E6%9C%AA%E6%BB%A1%E8%B6%B3%E7%9A%84%E4%BE%9D%E8%B5%96%E5%85%B3%E7%B3%BB%E2%80%9D.png)
我正在与Ubuntu 20.4 Focal Fossa和节点 v16.20.2。每当我运行sudo apt install npm
或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 (>= 6.11~)
Depends: node-abbrev (>= 1.1.1~) but it is not going to be installed
Depends: node-ajv but it is not going to be installed
Depends: node-ansi but it is not going to be installed
Depends: node-ansi-regex (>= 3.0~) but it is not going to be installed
Depends: node-ansi-styles but it is not going to be installed
Depends: node-ansistyles but it is not going to be installed
Depends: node-aproba but it is not going to be installed
Depends: node-archy (>= 1.0~) but it is not going to be installed
Depends: node-are-we-there-yet but it is not going to be installed
Depends: node-asap but it is not going to be installed
Depends: node-asn1 but it is not going to be installed
Depends: node-assert-plus but it is not going to be installed
Depends: node-asynckit but it is not going to be installed
Depends: node-aws4 but it is not going to be installed
Depends: node-aws-sign2 but it is not going to be installed
Depends: node-balanced-match but it is not going to be installed
Depends: node-bcrypt-pbkdf but it is not going to be installed
Depends: node-bl but it is not going to be installed
Depends: node-bluebird but it is not going to be installed
Depends: node-boxen but it is not going to be installed
Depends: node-brace-expansion but it is not going to be installed
Depends: node-builtin-modules but it is not going to be installed
Depends: node-builtins but it is not going to be installed
Depends: node-cacache but it is not going to be installed
Depends: node-call-limit but it is not going to be installed
Depends: node-camelcase but it is not going to be installed
Depends: node-caseless but it is not going to be installed
Depends: node-chalk but it is not going to be installed
Depends: node-chownr but it is not going to be installed
Depends: node-ci-info but it is not going to be installed
Depends: node-cli-boxes but it is not going to be installed
Depends: node-cliui but it is not going to be installed
Depends: node-clone but it is not going to be installed
Depends: node-co but it is not going to be installed
Depends: node-color-convert but it is not going to be installed
Depends: node-color-name but it is not going to be installed
Depends: node-colors but it is not going to be installed
Depends: node-columnify but it is not going to be installed
Depends: node-combined-stream but it is not going to be installed
Depends: node-concat-map but it is not going to be installed
Depends: node-concat-stream but it is not going to be installed
Depends: node-config-chain but it is not going to be installed
Depends: node-configstore but it is not going to be installed
Depends: node-console-control-strings but it is not going to be installed
Depends: node-copy-concurrently but it is not going to be installed
Depends: node-core-util-is but it is not going to be installed
Depends: node-cross-spawn but it is not going to be installed
Depends: node-crypto-random-string but it is not going to be installed
Depends: node-cyclist but it is not going to be installed
Depends: node-dashdash but it is not going to be installed
Depends: node-debug but it is not going to be installed
Depends: node-decamelize but it is not going to be installed
Depends: node-deep-extend but it is not going to be installed
Depends: node-defaults but it is not going to be installed
Depends: node-define-properties but it is not going to be installed
Depends: node-delayed-stream but it is not going to be installed
Depends: node-delegates but it is not going to be installed
Depends: node-detect-indent but it is not going to be installed
Depends: node-detect-newline but it is not going to be installed
Depends: node-dot-prop but it is not going to be installed
Depends: node-duplexer3 but it is not going to be installed
Depends: node-duplexify but it is not going to be installed
Depends: node-ecc-jsbn but it is not going to be installed
Depends: node-editor but it is not going to be installed
Depends: node-encoding but it is not going to be installed
Depends: node-end-of-stream but it is not going to be installed
Depends: node-err-code but it is not going to be installed
Depends: node-errno but it is not going to be installed
Depends: node-es6-promise but it is not going to be installed
Depends: node-escape-string-regexp but it is not going to be installed
Depends: node-execa but it is not going to be installed
Depends: node-extend but it is not going to be installed
Depends: node-extsprintf but it is not going to be installed
Depends: node-fast-deep-equal but it is not going to be installed
Depends: node-find-up but it is not going to be installed
Depends: node-flush-write-stream but it is not going to be installed
Depends: node-forever-agent but it is not going to be installed
Depends: node-form-data but it is not going to be installed
Depends: node-from2 but it is not going to be installed
Depends: node-fs.realpath but it is not going to be installed
Depends: node-fs-vacuum but it is not going to be installed
Depends: node-fs-write-stream-atomic but it is not going to be installed
Depends: node-function-bind but it is not going to be installed
Depends: node-gauge but it is not going to be installed
Depends: node-genfun but it is not going to be installed
Depends: node-get-caller-file but it is not going to be installed
Depends: node-getpass but it is not going to be installed
Depends: node-glob (>= 7.1.2~) but it is not going to be installed
Depends: node-got but it is not going to be installed
Depends: node-graceful-fs (>= 4.1.11~) but it is not going to be installed
Depends: node-gyp (>= 3.6.2~) but it is not going to be installed
Depends: node-har-schema but it is not going to be installed
Depends: node-har-validator but it is not going to be installed
Depends: node-has-flag but it is not going to be installed
Depends: node-has-unicode but it is not going to be installed
Depends: node-hosted-git-info (>= 2.6~) but it is not going to be installed
Depends: node-http-signature but it is not going to be installed
Depends: node-iconv-lite but it is not going to be installed
Depends: node-iferr but it is not going to be installed
Depends: node-import-lazy but it is not going to be installed
Depends: node-imurmurhash but it is not going to be installed
Depends: node-inflight but it is not going to be installed
Depends: node-inherits (>= 2.0.3~) but it is not going to be installed
Depends: node-ini (>= 1.3.5~) but it is not going to be installed
Depends: node-invert-kv but it is not going to be installed
Depends: node-ip but it is not going to be installed
Depends: node-ip-regex but it is not going to be installed
Depends: node-isarray but it is not going to be installed
Depends: node-isexe but it is not going to be installed
Depends: node-is-npm but it is not going to be installed
Depends: node-is-obj but it is not going to be installed
Depends: node-is-path-inside but it is not going to be installed
Depends: node-is-retry-allowed but it is not going to be installed
Depends: node-is-stream but it is not going to be installed
Depends: node-isstream but it is not going to be installed
Depends: node-is-typedarray but it is not going to be installed
Depends: node-jsbn but it is not going to be installed
Depends: node-jsonparse but it is not going to be installed
Depends: node-json-parse-better-errors but it is not going to be installed
Depends: node-json-schema but it is not going to be installed
Depends: node-json-schema-traverse but it is not going to be installed
Depends: node-jsonstream (>= 1.3.2~) but it is not going to be installed
Depends: node-json-stringify-safe but it is not going to be installed
Depends: node-jsprim but it is not going to be installed
Depends: node-latest-version but it is not going to be installed
Depends: node-lazy-property but it is not going to be installed
Depends: node-lcid but it is not going to be installed
Depends: node-libnpx but it is not going to be installed
Depends: node-locate-path but it is not going to be installed
Depends: node-lodash but it is not going to be installed
Depends: node-lockfile (>= 1.0.3~) but it is not going to be installed
Depends: node-lowercase-keys but it is not going to be installed
Depends: node-lru-cache (>= 4.1.1~) but it is not going to be installed
Depends: node-make-dir but it is not going to be installed
Depends: node-mem but it is not going to be installed
Depends: node-mime but it is not going to be installed
Depends: node-mime-types but it is not going to be installed
Depends: node-mimic-fn but it is not going to be installed
Depends: node-minimatch but it is not going to be installed
Depends: node-minimist but it is not going to be installed
Depends: node-mississippi but it is not going to be installed
Depends: node-mkdirp (>= 0.5.1~) but it is not going to be installed
Depends: node-move-concurrently but it is not going to be installed
Depends: node-ms but it is not going to be installed
Depends: node-mute-stream but it is not going to be installed
Depends: node-nopt but it is not going to be installed
Depends: node-normalize-package-data (>= 2.4~) but it is not going to be installed
Depends: node-npm-bundled but it is not going to be installed
Depends: node-npm-package-arg (>= 6.1.1) but it is not going to be installed
Depends: node-npmlog (>= 4.1.2~) but it is not going to be installed
Depends: node-number-is-nan but it is not going to be installed
Depends: node-oauth-sign but it is not going to be installed
Depends: node-object-assign but it is not going to be installed
Depends: node-once (>= 1.4~) but it is not going to be installed
Depends: node-opener but it is not going to be installed
Depends: node-osenv (>= 0.1.5~) but it is not going to be installed
Depends: node-os-locale but it is not going to be installed
Depends: node-os-tmpdir but it is not going to be installed
Depends: node-package-json but it is not going to be installed
Depends: node-parallel-transform but it is not going to be installed
Depends: node-path-exists but it is not going to be installed
Depends: node-path-is-absolute but it is not going to be installed
Depends: node-path-is-inside but it is not going to be installed
Depends: node-promise-inflight but it is not going to be installed
Depends: node-promise-retry but it is not going to be installed
Depends: node-promzard but it is not going to be installed
Depends: node-performance-now but it is not going to be installed
Depends: node-p-finally but it is not going to be installed
Depends: node-p-is-promise but it is not going to be installed
Depends: node-pify but it is not going to be installed
Depends: node-p-limit but it is not going to be installed
Depends: node-p-locate but it is not going to be installed
Depends: node-prepend-http but it is not going to be installed
Depends: node-process-nextick-args but it is not going to be installed
Depends: node-proto-list but it is not going to be installed
Depends: node-prr but it is not going to be installed
Depends: node-pseudomap but it is not going to be installed
Depends: node-psl but it is not going to be installed
Depends: node-pump but it is not going to be installed
Depends: node-pumpify but it is not going to be installed
Depends: node-punycode but it is not going to be installed
Depends: node-qs but it is not going to be installed
Depends: node-qw but it is not going to be installed
Depends: node-rc but it is not going to be installed
Depends: node-read (>= 1.0.7~) but it is not going to be installed
Depends: node-readable-stream but it is not going to be installed
Depends: node-read-package-json (>= 2.0.13~) but it is not going to be installed
Depends: node-registry-auth-token but it is not going to be installed
Depends: node-registry-url but it is not going to be installed
Depends: node-request (>= 2.83~) but it is not going to be installed
Depends: node-require-main-filename but it is not going to be installed
Depends: node-require-directory but it is not going to be installed
Depends: node-resolve-from (>= 4.0~) but it is not going to be installed
Depends: node-retry (>= 0.10.1~) but it is not going to be installed
Depends: node-rimraf (>= 2.6.2~) but it is not going to be installed
Depends: node-run-queue but it is not going to be installed
Depends: node-safe-buffer but it is not going to be installed
Depends: node-semver (>= 5.5~) but it is not going to be installed
Depends: node-set-blocking but it is not going to be installed
Depends: node-sha (>= 2.0.1~) but it is not going to be installed
Depends: node-shebang-command but it is not going to be installed
Depends: node-shebang-regex but it is not going to be installed
Depends: node-signal-exit but it is not going to be installed
Depends: node-slide (>= 1.1.6~) but it is not going to be installed
Depends: node-sorted-object but it is not going to be installed
Depends: node-slash but it is not going to be installed
Depends: node-semver-diff but it is not going to be installed
Depends: node-spdx-correct but it is not going to be installed
Depends: node-spdx-exceptions but it is not going to be installed
Depends: node-spdx-expression-parse but it is not going to be installed
Depends: node-spdx-license-ids but it is not going to be installed
Depends: node-sshpk but it is not going to be installed
Depends: node-ssri but it is not going to be installed
Depends: node-stream-each but it is not going to be installed
Depends: node-stream-iterate but it is not going to be installed
Depends: node-stream-shift but it is not going to be installed
Depends: node-strict-uri-encode but it is not going to be installed
Depends: node-string-decoder but it is not going to be installed
Depends: node-string-width but it is not going to be installed
Depends: node-strip-ansi (>= 4.0~) but it is not going to be installed
Depends: node-strip-json-comments but it is not going to be installed
Depends: node-strip-eof but it is not going to be installed
Depends: node-supports-color but it is not going to be installed
Depends: node-tar (>= 4.4~) but it is not going to be installed
Depends: node-term-size but it is not going to be installed
Depends: node-text-table but it is not going to be installed
Depends: node-through but it is not going to be installed
Depends: node-through2 but it is not going to be installed
Depends: node-timed-out but it is not going to be installed
Depends: node-tough-cookie but it is not going to be installed
Depends: node-tunnel-agent but it is not going to be installed
Depends: node-tweetnacl but it is not going to be installed
Depends: node-typedarray but it is not going to be installed
Depends: node-uid-number but it is not going to be installed
Depends: node-unique-filename but it is not going to be installed
Depends: node-unique-string but it is not going to be installed
Depends: node-unpipe but it is not going to be installed
Depends: node-url-parse-lax but it is not going to be installed
Depends: node-util-deprecate but it is not going to be installed
Depends: node-uuid but it is not going to be installed
Depends: node-validate-npm-package-name but it is not going to be installed
Depends: node-verror but it is not going to be installed
Depends: node-which (>= 1.3~) but it is not going to be installed
Depends: node-which-module but it is not going to be installed
Depends: node-wide-align but it is not going to be installed
Depends: node-widest-line but it is not going to be installed
Depends: node-wrap-ansi but it is not going to be installed
Depends: node-wrappy but it is not going to be installed
Depends: node-wcwidth.js but it is not going to be installed
Depends: node-write-file-atomic but it is not going to be installed
Depends: node-xdg-basedir but it is not going to be installed
Depends: node-xtend but it is not going to be installed
Depends: node-yargs but it is not going to be installed
Depends: node-yargs-parser but it is not going to be installed
Depends: node-yallist but it is not going to be installed
Depends: node-y18n but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
我尝试了网上的所有解决方案,但都没有解决这个问题,解决方案包括:
跑步
apt-get -f install
跑步
sudo dpkg --configure -a
跑步
sudo apt-get autoclean
删除 npm 和 nodejs 并重新安装它们。
跑去
sudo apt-mark showhold
看看是否有保留的包裹,但没有。我也尝试过使用资质下载 npm 并且它显示了一个解决方案,但是,当我输入“Y”接受解决方案时出现以下内容:
不会安装、升级或删除任何软件包。升级了 0 个软件包,新安装了 0 个软件包,要删除 0 个软件包,未升级 0 个软件包。需要获取 0 B 档案。解压后将使用 0 B。
调查具体的依赖关系问题并手动解决它们。当我尝试安装时出现错误节点gyp以下内容(即使安装了 libnode-dev):
以下软件包具有未满足的依赖项:node-gyp:依赖:libnode-dev,但不会安装 E:无法纠正问题,您持有损坏的软件包。
当然,一开始我sudo apt-get update
也尝试过跑步。sudo apt-get upgrade