20

I followed this gist https://gist.github.com/Goddard/5500157 to install nodejs and npm, but after running it neither node --version or npm --version could be ran, giving an error of command not found. I was able to uninstall nodejs, but had to go into the temp directory described in the script and do a make uninstall to get npm to leave.

Now in an attempt to install nodejs and npm again i used this link instead http://www.andreagrandi.it/2013/02/08/how-to-install-latest-stable-node-js-on-ubuntu/ , but if I try and install both nodejs and npm together I get this error message.

sudo apt-get install nodejs npm

The following packages have unmet dependencies:
   nodejs : Conflicts: npm
E: Unable to correct problems, you have held broken packages.

If I just install nodejs that works fine.

sudo apt-get install nodejs

node --version
v0.10.15

But now if I try to install npm it gives me this error message

sudo apt-get install npm 

The following packages have unmet dependencies:
npm : Depends: nodejs (>= 0.6.19~dfsg1-3) but it is not going to be installed
   Depends: nodejs-dev
   Depends: node-node-uuid but it is not going to be installed
   Depends: node-request but it is not going to be installed
   Depends: node-mkdirp but it is not going to be installed
   Depends: node-minimatch but it is not going to be installed
   Depends: node-semver but it is not going to be installed
   Depends: node-ini but it is not going to be installed
   Depends: node-graceful-fs but it is not going to be installed
   Depends: node-abbrev but it is not going to be installed
   Depends: node-nopt but it is not going to be installed
   Depends: node-fstream but it is not going to be installed
   Depends: node-rimraf but it is not going to be installed
   Depends: node-tar but it is not going to be installed
   Depends: node-which but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I am using Ubuntu 13.04. Any help is appreciated. I dont know much about node.js and npm. I was trying to start learning how to use these so probably my in-experience is showing.

lumberjacked
  • 377
  • 1
  • 4
  • 9
  • 2
    The nodejs package you installed from the PPA includes npm since v0.10.0. In other words - you should have npm installed already (because of sudo apt-get install nodejs). Try to run npm to confirm. Also see the [offical installation guide](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager) (the one you followed is a copy of it, but the official one has a few extra details). – cyberx86 Aug 07 '13 at 17:38
  • Thank you -- you are right everything works correctly if you just install nodejs and then run npm --version. I didn't think about checking whether they came together, I just assumed they were separate. – lumberjacked Aug 09 '13 at 01:03
  • 2017 and it is still possible to get to this point, with the same confusing error message for a non-error :( – Efren Feb 06 '18 at 05:21

1 Answers1

26

The nodejs package you installed from the PPA includes npm since v0.10.0. Since you have v0.10.15, when you ran sudo apt-get install nodejs you also installed npm. Try to run npm to confirm.

Also see the offical installation guide (the one you followed is a copy of it, but the official one has a few extra details).

cyberx86
  • 20,620
  • 1
  • 60
  • 80
  • 2
    If npm is already installed, why is apt confused? Is it broken anyway? – Efren Feb 06 '18 at 05:17
  • The same situation, I installed via `curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -` , which already had npm installed. – Nirojan Selvanathan Jun 17 '19 at 14:00
  • This answer is obsolete. The link is not valid anymore and the problem still persists with node v12 installed using the official Ubuntu/Debian instructions: https://github.com/nodesource/distributions/blob/master/README.md#debinstall – Gabriel Petrovay Sep 02 '20 at 07:51
  • I don't understand how this solves the problem. It just explains what's happened. – Owl May 17 '22 at 12:11