npm :依赖:node-gyp (>= 3.6.2~) 但它不会被安装

npm : Depends: node-gyp (>= 3.6.2~) but it is not going to be installed

提问人:user3523406 提问时间:4/2/2019 最后编辑:toydarianuser3523406 更新时间:5/19/2023 访问量:28945

问:

我执行了以下步骤:

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

并得到

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.

我按照建议做了,但它导致了另一个问题:

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

我错过了什么?

节点 .js npm

评论

1赞 bereket gebredingle 4/2/2019
askubuntu.com/questions/899756/......
0赞 user3523406 4/2/2019
不幸的是,我试过了,但没有用。我更新了我的问题。
0赞 igcp 4/26/2019
我遇到了同样的问题,然后我尝试为我工作:askubuntu.com/questions/1057737/......

答:

29赞 Welder Lourenço 3/5/2020 #1

对于 Ubuntu 18.x 和 20.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 -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -
sudo apt-get install -y nodejs
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn
node -v && npm -v                

评论

6赞 Fellipe Sanches 6/9/2020
在某些情况下:node -v & npm -v
3赞 SEoF 12/15/2020
除了添加不必要的纱线钻头外,这是正确的方法
1赞 Eric J. 1/21/2022
这专门安装节点 14。对于其他版本,请参阅 github.com/nodesource/distributions#debinstall(仍需要初始清洁步骤)
1赞 Agung Sudrajat 5/19/2022
一段时间后,这个就像一个魅力。谢谢!
25赞 Schrödinger's Cat 8/24/2020 #2

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

sudo apt install libssl1.1=1.1.1f-1ubuntu2
sudo apt install npm

检查这个

评论

9赞 SEoF 12/15/2020
这确实是一个相当糟糕的建议。您建议人们降级他们的 libssl1.1 版本 - 导致安全更新丢失!
7赞 toydarian 4/30/2021 #3

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

解决方案是.
之后,命令起作用了。
apt-get install nodejs yarnnpm

评论

0赞 phi 1/8/2022
这对我有用。看起来很难,就像 16.x 版的 nodjs 无论如何都包含 npm 一样?输出可能是安装程序只是忽略了这个东西。## Run sudo apt-get install -y nodejs to install Node.js 16.x *and* npmyarn
0赞 superqwerty 5/19/2023 #4

在 Ubuntu 22.04 上安装 Node 18 和 yarn:

# Preinstallation
sudo apt remove --purge nodejs npm
sudo apt clean
sudo apt autoclean
sudo apt install -f
sudo apt autoremove

# Install node repo
wget -q https://deb.nodesource.com/setup_18.x -O nodejs_setup_18.x.sh
sed -ri "/^exec_cmd 'apt-get update/ s/^/#/g" ./nodejs_setup_18.x.sh
sed -ri "s@(print_status 'Running \`apt-get update\` for you...')@\1\napt-get update -o Dir::Etc::sourcelist='sources.list.d/nodesource.list' -o Dir::Etc::sourceparts='-' -o APT::Get::List-Cleanup='0'@" ./nodejs_setup_18.x.sh
sudo bash ./nodejs_setup_18.x.sh

# Install node package
sudo apt-get install nodejs

# Install yarn repo
wget -q https://dl.yarnpkg.com/debian/pubkey.gpg -O- | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update -o Dir::Etc::sourcelist='sources.list.d/yarn.list' -o Dir::Etc::sourceparts='-' -o APT::Get::List-Cleanup='0'

# Install yarn package
sudo apt-get install yarn