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

dkqlctbz  于 2023-05-22  发布在  Node.js
关注(0)|答案(4)|浏览(402)

我做了以下步骤:

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

我错过了什么?

ifmq2ha2

ifmq2ha21#

对于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
omtl5h9j

omtl5h9j2#

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

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

Check this

m528fe3b

m528fe3b3#

当我试图在基于buster的docker容器中安装nodejsnpm时,我遇到了同样的事情。
现在看来,您需要安装yarn,这将需要npm
解为apt-get install nodejs yarn
然后,npm命令工作。

t9aqgxwy

t9aqgxwy4#

在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

相关问题