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

Anton Dozortsev
  • 1,122
  • 10
  • 21
user809829
  • 253
  • 1
  • 2
  • 5
  • 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 05:49

4 Answers4

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.

Anton Dozortsev
  • 1,122
  • 10
  • 21
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.

Oli
  • 289,791
  • 117
  • 680
  • 835
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
barbolo
  • 203
  • 2
  • 6
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.

Bidyut
  • 759
  • 7
  • 14
  • 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 05:17
  • I don't think, this answer is relevant to the question – Sivabalan Nov 16 '17 at 05:15