12

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 :(

  • 1
    Which Ubuntu version? I'm on 13.04 and it works fine. – Eric Carvalho Jun 25 '13 at 13:16
  • 1
    12.04 LTS is the version. – user809829 Jun 25 '13 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 '14 at 5:49
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.

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.

  • 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 '13 at 13:31
  • Yes, I've added ppa:chris-lea/node.js as nodejs.org tells. – user809829 Jun 25 '13 at 13:39
  • Any ideas on what to do? :( – user809829 Jun 26 '13 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 '13 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.

  • 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 '16 at 19:08
  • hmm.. thats true. I will keep that in mind from next time. Thanks! – Bidyut Jul 27 '16 at 5:17
  • I don't think, this answer is relevant to the question – Sivabalan Nov 16 '17 at 5:15

protected by Community Feb 2 '15 at 18:43

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.