18

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.

  • 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 (the one you followed is a copy of it, but the official one has a few extra details). – cyberx86 Aug 7 '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 9 '13 at 1:03
  • 2017 and it is still possible to get to this point, with the same confusing error message for a non-error :( – Efren Feb 6 '18 at 5:21
19

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).

|improve this answer|||||
  • 2
    If npm is already installed, why is apt confused? Is it broken anyway? – Efren Feb 6 '18 at 5: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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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