Having problem with installing npm in ubuntu 16.04.3

9,464

Solution 1

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

Solution 2

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.

Share:
9,464

Related videos on Youtube

sadia
Author by

sadia

I am a systematic, organized, hardworking, and dedicated team player having an experience of 8 years with an analytical bent of mind. My work is my passion and I have often indulged deep to achieve my goals stretching to the point of risk. I strongly believe in pushing for challenging limits at the work front and I would love to be a part of an organization that provides me scope to do so.

Updated on September 18, 2022

Comments

  • sadia
    sadia almost 2 years

    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
    
    • Scott Stensland
      Scott Stensland over 6 years
      npm comes bundled together with an install of nodejs ... never a need to do a separate npm install
    • David Foerster
      David Foerster over 6 years
      Could you please edit your question to include the full, verbatim output of sudo apt-get upgrade -f npm node-gyp? Thanks.
    • sadia
      sadia over 6 years
      @DavidFoerster I added output of the command in Question, please see
    • David Foerster
      David Foerster over 6 years
      Thank. Let's go further! What's the output of sudo apt-get upgrade -f libssl-dev?
    • sadia
      sadia over 6 years
      @DavidFoerster issue is solved, I put my solution as an answer in this thread. Thanks :)
  • sadia
    sadia over 6 years
    nodejs already installed in my system, however i am facing issue with npm
  • Deki Akbar
    Deki Akbar over 6 years
    it will install nodejs and npm... did you try it??
  • sadia
    sadia over 6 years
    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"
  • Scott Stensland
    Scott Stensland over 6 years
    issue sudo apt-get install build-essential curl then re-do above steps in this answer
  • Deki Akbar
    Deki Akbar over 6 years
    you can install curl using this tutorial codebind.com/linux-tutorials/install-curl-ubuntu-16-04