13

I'm trying to install nodejs and npm, however, it fails. This is my terminal:

sudo apt-get install nodejs npm
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:
nodejs : Conflicts: npm
E: Unable to correct problems, you have held broken packages.

What to do? I'm kinda lost :(

3
  • 1
    Which Ubuntu version? I'm on 13.04 and it works fine. Jun 25, 2013 at 13:16
  • 1
    12.04 LTS is the version.
    – user809829
    Jun 25, 2013 at 13:32
  • 1
    Oli's answer worked for me. Rather, what he said was true for me, which was, that I already had npm (from installing nodejs from the repos) and did not need to install npm separately. I am writing this as an answer because I can neither upvote his answer (which requires 15 reputation) nor can I comment on his answer (it requires 50!).
    – Devesh
    Mar 17, 2014 at 5:49

4 Answers 4

14

Just execute this commands!

Installing Node.js via :

sudo apt-get install -y python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

Check version:

$ npm -v
1.4.9
$ node -v
v0.10.28

For more info visit this guide.

1
4

Sounds like you have one of the nodejs PPAs installed. One I use has npm distributed as part of the nodejs package and it's impossible and unneccessary to install both.

Install nodejs and see if you can run npm.

4
  • I get a lot of unmet dependencies. I can install all of them except nodejs-dev which fails due to nodejs-dev : Depends: nodejs (= 0.8.22-1chl1~precise1) but it is not going to be installed
    – user809829
    Jun 25, 2013 at 13:31
  • Yes, I've added ppa:chris-lea/node.js as nodejs.org tells.
    – user809829
    Jun 25, 2013 at 13:39
  • Any ideas on what to do? :(
    – user809829
    Jun 26, 2013 at 8:39
  • nodejs-dev looks like it has fallen behind. Talk to Chris Lea and ask if he can update the PPA accordingly.
    – Oli
    Jun 26, 2013 at 8:43
0

You should follow the Node.js guide

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

You can follow this this link to setup npm in your system. The link is comprehensive for setting up a npm in a system.

3
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes
    – storm
    Jul 26, 2016 at 19:08
  • hmm.. thats true. I will keep that in mind from next time. Thanks!
    – Bidyut
    Jul 27, 2016 at 5:17
  • I don't think, this answer is relevant to the question
    – Sivabalan
    Nov 16, 2017 at 5:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .