我执行了以下步骤:
npm install#导致以下错误
以下软件包具有未满足的依赖性: nodejs:冲突:npm npm:取决于:node-gyp(> = 3.6.2〜)但不会被安装 E:无法纠正问题,您拿着破损的包裹。
我在评论中建议
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
我想念什么?
提前谢谢
答案 0 :(得分:13)
如果您在Ubuntu 20.04中遇到此问题,请执行以下操作:
sudo apt install libssl1.1=1.1.1f-1ubuntu2
sudo apt install npm
答案 1 :(得分:6)
对于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 -
sudo apt-get update && sudo apt-get install yarn
nodejs -v && npm -v
答案 2 :(得分:1)
当我尝试在基于 buster 的 docker 容器中安装 nodejs
和 npm
时,我遇到了同样的问题。
现在看来,您需要安装 yarn
,这将带走 npm
。
解决方案是apt-get install nodejs yarn
。
之后,npm
命令起作用了。