Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I was lucky enough to get a Raspberry Pi under the tree this year and I've had a bit of fun playing with Node.js on the device. However, Node.js is much more interesting when you can pull down packages and plug them into your applications - and this is where I am having some trouble.

If I attempt to install NPM along with Node.js with the following command:

sudo apt-get install nodejs npm

I get the following error:

pi@raspberrypi ~ $ 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 : Breaks: npm (< 1.1.4~dfsg-2~) but 1.1.4~dfsg-1 is to be installed
 npm : Depends: node-semver but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I'm pretty new to how package management works with Debian-based Linux operating systems and don't know much at all about how the node.js community has structured their specific packages. It is worth noting that installing node.js by itself works just fine, and if I try to install NPM just by itself this is what I get.

pi@raspberrypi ~ $ sudo apt-get install 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:
 npm : Depends: nodejs but it is not going to be installed
       Depends: nodejs-dev 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'm not sure, but my gut is telling me that it is something to do with the node-semver package. If I install the nodejs package by itself and then attempt to install node-semver this is the output that I get.

pi@raspberrypi ~ $ sudo apt-get install node-semver
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:
 node-semver : Depends: nodejs but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Any pointers?

share|improve this question

migrated from stackoverflow.com Dec 28 '12 at 0:08

This question came from our site for professional and enthusiast programmers.

4 Answers 4

up vote 1 down vote accepted

Try installing them all together:

sudo apt-get install nodejs npm node-semver
share|improve this answer

If you are running into problems with the binary packages I'd recommend you compile it yourself, this way you get a better idea of while something is failing/the binary packages may be for a different type of processor (not ARM).

I suggest checking out https://gist.github.com/3301813 for Raspberry Pi NodeJS Compiling instructions.

share|improve this answer
    
Thanks Ben. I had come across that article before. I assumed that NPM might be separate to the Node.js source tree? –  Mitch Denny Dec 27 '12 at 2:39
    
NPM is separate at source github.com/isaacs/npm however the recent versions for nodejs generally come with npm bundled. –  Ben Evans Dec 27 '12 at 21:13
    
Thanks for the info Ben. Appreciate it. –  Mitch Denny Dec 27 '12 at 23:31

As Ben pointed out I'd suggest to compile Node.js on your own on the Raspberry Pi. Since 0.8.10 (or so) this is possible without further ado. Simply

$ ./configure
$ make
$ sudo make install

and that's it. Then Node.js will be installed including npm.

Works like a charme :-)!

share|improve this answer
    
Thanks Golo. Minitech provided an answer which worked better for me. The Raspberry Pi is quite slow so I would think that building, then installing would be a bit more painful. –  Mitch Denny Dec 27 '12 at 23:05
    
Please have a look at the version of Node.js being installed using apt-get, and then compare this version to the current version of Node.js, and you'll know why I did not suggest to use apt-get ... ;-) –  Golo Roden Jan 3 '13 at 12:38
    
I've made some pre-compiled tarballs that can be used on a Raspberry Pi if you don't really want to wait for the source to compile. gist.github.com/3245130 –  Adam M-W Jun 18 '13 at 4:37

Try to follow this post. I manage to run npm on /opt/node/npm, but when I copy it to /usr/bin/ it misses 'npmlog'.

share|improve this answer
    
IT is preferred that you copy the steps into the answer while attributing your source for additional information, in case the source site goes down, page is deleted or moved, etc. At least a summary of the broad strokes of the process. –  Tevo D Aug 23 '13 at 13:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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