【问题标题】:Ubuntu apt-get unmet dependencies for NPMUbuntu apt-get 未满足的 NPM 依赖项
【发布时间】:2019-02-05 18:33:14
【问题描述】:

我正在尝试安装 NPM。为此,我跑了:

sudo apt-get install nodejs

这很成功。然后我跑了:

sudo apt-get install npm

 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: node-gyp (>= 0.10.9) but it is not going to be installed
 E: Unable to correct problems, you have held broken packages.

尝试安装 node-gyp 会导致“未满足的依赖项”的无尽路径。

我遵循了这些说明并且有 0 个未升级的软件包; https://askubuntu.com/questions/140246/how-do-i-resolve-unmet-dependencies-after-adding-a-ppa

我禁用了所有其他软件源,但仍有问题。对于其他软件包(hhvm 和 mono),我一直遇到这个问题。我可以做些什么来解决这些问题?

【问题讨论】:

  • npm 如今随 nodejs 一起提供。你确定你还没有吗?
  • 当我安装 nodejs v.4.0.0 时发生这种情况,但奇怪的是我像往常一样使用 npm :)
  • 我尝试运行 NPM 并得到“当前未安装程序 'npm'。您可以通过键入:sudo apt-get install npm 来安装它”

标签: node.js ubuntu npm apt-get


【解决方案1】:

我在安装 npm 时遇到了完全相同的症状和错误消息。

参考Node Package Manager got corrupted

您可以执行以下操作

sudo apt-get remove nodejs npm ## remove existing nodejs and npm packages
sudo apt-get install curl  
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs  

这适用于我的 Ubuntu 16.04.2

【讨论】:

    【解决方案2】:

    sudo apt-get cleansudo apt-get -f install

    clean 清除 .deb 文件的本地缓存。

    -f 表示“修复损坏”。

    【讨论】:

    【解决方案3】:

    发生这种情况是因为 nodejs 已经安装在比最新 ubuntu 更新的版本中,可能来自 PPA。如果你把当前的nodejs去掉,安装ubuntu提供的那个,就可以安装npm了。

    您必须使用 dpkg 将其删除以避免删除依赖项:

    sudo dpkg -r --force-depends nodejs
    

    【讨论】:

      【解决方案4】:

      在 Ubuntu 18.04 上,我安装了阻止安装 npm 依赖项的软件包:

      # apt install npm
      ...
       npm : Hängt ab von: node-gyp (>= 0.10.9) soll aber nicht installiert werden
      
      # apt install node-gyp
      ...
       node-gyp : Hängt ab von: nodejs-dev soll aber nicht installiert werden
      
      # apt install node-gyp nodejs-dev
      ...
       nodejs-dev : Hängt ab von: libssl1.0-dev (>= 1.0.2) soll aber nicht installiert werden
      
      # apt install node-gyp nodejs-dev libssl1.0-dev
      ...
      Die folgenden Pakete werden ENTFERNT:
        libcurl4-openssl-dev libneon27-dev libssl-dev
      

      所以问题是我安装了这三个包:

      libcurl4-openssl-dev libneon27-dev libssl-dev
      

      删除它们后,我可以毫无问题地安装 npm。

      【讨论】:

        【解决方案5】:

        在运行npm install 之前,执行以下步骤可能会有所帮助:

        使用rm -rf node_modules/ 删除 node_modules 运行npm cache clean

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2019-09-12
          • 2016-08-29
          • 1970-01-01
          • 2014-11-01
          • 2017-11-17
          • 1970-01-01
          • 2017-07-17
          • 2020-09-11
          相关资源
          最近更新 更多