1

After installing node.js I execute this command:

sudo apt-get install npm

And getting error:

The following packages have unmet dependencies:
  npm : Depends: node-gyp (>= 0.10.9) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
$ sudo apt-get upgrade -f npm node-gyp
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... 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:
  nodejs-dev : Depends: libssl-dev (>= 1.0.0g) but it is not going to be installed
E: Broken packages
David Foerster
  • 35,754
  • 55
  • 92
  • 145
sadia
  • 151
  • 1
  • 8

2 Answers2

4

After facing numerous errors, finally get success to resolve the issues. Here are the steps I followed.

First I installed "curl" by following http://sourcedigit.com/20782-install-curl-ubuntu-via-command-line/ . This article provides two ways to install curl and I successfully installed curl using "Alternate Method To Install Curl".

Then I executed commands in sequence

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install nodejs

By executing above nodejs command, node js version 8 is installed with npm version 5.3.0

David Foerster
  • 35,754
  • 55
  • 92
  • 145
sadia
  • 151
  • 1
  • 8
1

add python libraries for that:

sudo apt-get install python-software-properties

add the ppa for latest nodejs with this command :

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

then try :

sudo apt install -y nodejs

I hope this will work for you, because this works for me.

Deki
  • 635
  • 4
  • 14
  • 2
    nodejs already installed in my system, however i am facing issue with npm – sadia Sep 26 '17 at 13:15
  • it will install nodejs and npm... did you try it?? – Deki Sep 26 '17 at 13:18
  • first command is successfully executed but on second command getting curl error program is not found. but when i tried to install curl again get dependency error "The following packages have unmet dependencies: curl : Depends: libcurl3-gnutls (= 7.47.0-1ubuntu2) but 7.47.0-1ubuntu2.2 is to be installed" – sadia Sep 26 '17 at 13:25
  • issue sudo apt-get install build-essential curl then re-do above steps in this answer – Scott Stensland Sep 26 '17 at 13:39
  • you can install curl using this tutorial http://www.codebind.com/linux-tutorials/install-curl-ubuntu-16-04/ – Deki Sep 26 '17 at 13:39