npm : 取决于: node-gyp (>= 3.6.2~) 但它不会被安装

use*_*406 8 node.js npm

我做了以下步骤:

git clone https://github.com/nibtehaz/NORTH-app.git
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
npm install # which caused the following error
Run Code Online (Sandbox Code Playgroud)

并得到

The following packages have unmet dependencies:
 nodejs : Conflicts: npm
 npm : Depends: node-gyp (>= 3.6.2~) 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 node-gyp
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:
 node-gyp : Depends: libnode-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

小智 27

如果您在 Ubuntu 20.04 中遇到此问题,请执行以下操作:

sudo apt install libssl1.1=1.1.1f-1ubuntu2
sudo apt install npm
Run Code Online (Sandbox Code Playgroud)

检查这个

  • 这确实是一个非常糟糕的建议。您建议人们降级他们的 libssl1.1 版本 - 导致安全更新丢失! (3认同)

Wel*_*nço 15

对于 Ubuntu 18.x 和 19.04,这是它的作用:

sudo apt remove --purge nodejs npm

sudo apt clean

sudo apt autoclean

sudo apt install -f

sudo apt autoremove

sudo apt install curl

cd ~

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

sudo apt-get install -y nodejs

curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

nodejs -v && npm -v
Run Code Online (Sandbox Code Playgroud)

  • 在某些情况下:node -v && npm -v (4认同)
  • 除了添加不必要的纱头之外,这是正确的做法 (3认同)

toy*_*ian 7

当我尝试在基于buster的docker容器中nodejs安装时,我遇到了同样的事情。 看来现在,你需要安装这将需要。npm
yarnnpm

解决办法是apt-get install nodejs yarn
之后,npm命令就起作用了。