我使用这个脚本来安装基本软件,但由于网速较慢而不得不中断.现在当我点击时$ 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.
Run Code Online (Sandbox Code Playgroud)
小智 66
如果sudo apt-get install -f <package-name>不起作用,请尝试aptitude:
sudo apt-get install aptitude
sudo aptitude install <package-name>
Run Code Online (Sandbox Code Playgroud)
能力将尝试解决问题.
举个例子,在我的情况下,我在尝试安装时仍会收到一些错误libcurl4-openssl-dev:
sudo apt-get install -f libcurl4-openssl-dev
Run Code Online (Sandbox Code Playgroud)
所以我尝试了aptitude,事实证明我必须降级一些包.
Run Code Online (Sandbox Code Playgroud)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)
小智 23
让Ubuntu修复未满足的依赖项和破坏的包的命令是
sudo apt-get install -f
Run Code Online (Sandbox Code Playgroud)
从手册页:
-f, - fix-broken Fix; 尝试纠正具有破坏的依赖关系的系统.此选项与install/remove一起使用时,可以省略任何包以允许APT推断出可能的解决方案.如果指定了包,则必须完全解决问题.第一次运行APT时有时需要该选项; APT本身不允许在系统上存在破坏的包依赖性.系统的依赖结构可能是如此腐败,以至于需要手动干预(这通常意味着使用dselect(1)或dpkg - 删除一些违规的包)
运行命令时,Ubuntu会尝试自行修复.完成后,您可以通过再次运行命令来测试它是否有效,并且您应该收到类似于以下内容的输出:
读取包列表...完成构建依赖关系树读取状态信息...完成0升级,0新安装,0删除,2未升级.
Aka*_*pal 20
首先试试这个
sudo apt-get update
sudo apt-get clean
sudo apt-get autoremove
Run Code Online (Sandbox Code Playgroud)
如果错误仍然存在,请执行此操作
sudo apt --fix-broken install
sudo apt-get update && sudo apt-get upgrade
sudo dpkg --configure -a
sudo apt-get install -f
Run Code Online (Sandbox Code Playgroud)
然后再试一次:
sudo apt-get install npm
Run Code Online (Sandbox Code Playgroud)
但是,如果它仍然无法解决问题,请检查依赖关系使用sudo dpkg --configure -a并逐个删除它们.假设依赖关系在npm然后为此,
sudo apt-get remove nodejs
sudo apt-get remove npm
Run Code Online (Sandbox Code Playgroud)
然后转到/etc/apt/sources.list.d并删除任何节点列表(如果有).然后做一个
sudo apt-get update
Run Code Online (Sandbox Code Playgroud)
然后再次使用检查依赖关系问题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 -
Run Code Online (Sandbox Code Playgroud)
然后安装Node.js包.
sudo apt-get install -y nodejs
Run Code Online (Sandbox Code Playgroud)
上面的答案也适用于一般情况(对于像django等其他软件包的依赖),就在前两个进程对你所面对的包使用相同的进程之后.
Rus*_*sso 12
安装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
Run Code Online (Sandbox Code Playgroud)
Nir*_*han 10
当我从最新的稳定版本安装 node 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.
Run Code Online (Sandbox Code Playgroud)
sudo apt install aptitude
Run Code Online (Sandbox Code Playgroud)
然后
sudo aptitude install npm
Run Code Online (Sandbox Code Playgroud)
来源: https: //askubuntu.com/a/978353/458947
我尝试了很多方法,但下面的工作就像魅力......
在此命令后运行这些:-
curl -sL https://deb.nodesource.com/setup_14.x 565 | sudo -E bash -
sudo apt-get install -y nodejs
Run Code Online (Sandbox Code Playgroud)
现在检查…
node -v
npm -v
Run Code Online (Sandbox Code Playgroud)
这是 npm 包中有关依赖项的错误: https://askubuntu.com/questions/1088662/npm-depends-node-gyp-0-10-9-but-it-is-not-going-to-be -已安装
已报告错误。上述内容可能不起作用,具体取决于您已经安装的内容,至少对我来说在最新的 Ubuntu 18.04 LTS 上不起作用。
我遵循建议的依赖项并按照上面的链接建议安装了它们:
sudo apt-get install nodejs-dev node-gyp libssl1.0-dev
Run Code Online (Sandbox Code Playgroud)
进而
sudo apt-get install npm
Run Code Online (Sandbox Code Playgroud)
如果您受到影响,请订阅该错误:
bugs.launchpad.net/ubuntu/+source/npm/+bug/1517491
bugs.launchpad.net/ubuntu/+source/npm/+bug/1809828
| 归档时间: |
|
| 查看次数: |
137265 次 |
| 最近记录: |