Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

node.js

npm

I did the following steps:

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

and got

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.

I did what was suggested, but it lead to another problem:

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

What did I miss?

like image 216
user3523406 Avatar asked Apr 01 '19 23:04

user3523406


Video Answer


3 Answers

If you face this issue in Ubuntu 20.04 do:

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

Check this

like image 165
nikhil Avatar answered Oct 22 '22 19:10

nikhil


For Ubuntu 18.x and 20.04, here's what does it:

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                
like image 28
Welder Lourenço Avatar answered Oct 22 '22 20:10

Welder Lourenço


I ran into the same thing, when I tried to install nodejs and npm in a buster-based docker container.
It seems that now, you need to install yarn which will take npm along.

The solution was apt-get install nodejs yarn.
Afterwards, the npm command worked.

like image 5
toydarian Avatar answered Oct 22 '22 19:10

toydarian