I have a Raspberry Pi Model B+, and currently I have been working with web development. Today, I successfully compiled the source code of Node.js on my Raspberry Pi, and I managed to install it without any hassle. My current Node.js version is version 0.8.16 which comes with the NPM module manager (1.1.69). When I try and install the speaker module (node-speaker), I get a bunch of errors. I really need help with installing this particular module.

This is the error NPM throws at me:

root@raspberrypi:/# npm install speaker
npm http GET https://registry.npmjs.org/speaker
npm http 304 https://registry.npmjs.org/speaker
npm http GET https://registry.npmjs.org/bindings
npm http GET https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/nan
npm http GET https://registry.npmjs.org/readable-stream
npm http 304 https://registry.npmjs.org/readable-stream
npm http 304 https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/debug
npm http 304 https://registry.npmjs.org/nan
npm http GET https://registry.npmjs.org/ms/0.6.2
npm http GET https://registry.npmjs.org/core-util-is
npm http GET https://registry.npmjs.org/isarray/0.0.1
npm http GET https://registry.npmjs.org/string_decoder
npm http GET https://registry.npmjs.org/inherits
npm http 304 https://registry.npmjs.org/core-util-is
npm http 304 https://registry.npmjs.org/isarray/0.0.1
npm http 304 https://registry.npmjs.org/ms/0.6.2
npm http 304 https://registry.npmjs.org/string_decoder
npm http 304 https://registry.npmjs.org/inherits

> [email protected] install /node_modules/speaker
> node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/roo                                                                                        t/.node-gyp/0.8.16"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/node_modules/s                                                                                        peaker/.node-gyp"
gyp http GET http://nodejs.org/dist/v0.8.16/node-v0.8.16.tar.gz
gyp http 200 http://nodejs.org/dist/v0.8.16/node-v0.8.16.tar.gz
make: Entering directory '/node_modules/speaker/build'
  CC(target) Release/obj.target/output/deps/mpg123/src/output/alsa.o
../deps/mpg123/src/output/alsa.c:19:28: fatal error: alsa/asoundlib.h: No such f                                                                                        ile or directory
compilation terminated.
deps/mpg123/output.target.mk:92: recipe for target 'Release/obj.target/output/de                                                                                        ps/mpg123/src/output/alsa.o' failed
make: *** [Release/obj.target/output/deps/mpg123/src/output/alsa.o] Error 1
make: Leaving directory '/node_modules/speaker/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_                                                                                        modules/node-gyp/lib/build.js:232:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack     at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System Linux 3.12.35+
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/b                                                                                        in/node-gyp.js" "rebuild"
gyp ERR! cwd /node_modules/speaker
gyp ERR! node -v v0.8.16
gyp ERR! node-gyp -v v0.7.3
gyp ERR! not ok
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the speaker package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls speaker
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.12.35+
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "speaker"
npm ERR! cwd /
npm ERR! node -v v0.8.16
npm ERR! npm -v 1.1.69
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /npm-debug.log
npm ERR! not ok code 0

It seems like the problem starts when NPM tries to execute this command:

node-gyp rebuild

How can I fix this problem?


3 Answers 3


I have seen this before on the Pi, where packages that are compiled by gyp refuse to compile or install. One method of getting around this problem is to install a precompiled binary.

To do this start by making sure that your Pi is up to date by entering the following in the terminal:

sudo apt-get update && sudo apt-get upgrade

next download node (this will download the latest stable package):

wget http://node-arm.herokuapp.com/node_latest_armhf.deb

then install the package:

sudo dpkg -i node_latest_armhf.deb

check the installation is working (the following command will return the version number of node):

node -v

you may also want to check the npm version as well:

npm -v

reference: https://learn.adafruit.com/node-embedded-development/installing-node-dot-js


You should install libasound2 first:

sudo apt-get install libasound2-dev
  • Thank you!!!!! This was the answer. I do not know how the other answer could work. But I guess there we other problems than the missing package.
    – func0der
    Commented May 23, 2015 at 14:49

Just to add from what has been previously said, I had to do an extra step to get everything fixed:

  1. Install libasound (sudo apt-get install libasound2-dev)
  2. Install Qt5:
$ sudo apt-get update
$ sudo apt-get upgrade

Buster OS

$ sudo apt-get install qt5-default
$ sudo apt-get install qtcreator
$ sudo apt-get install qtdeclarative5-dev

Bullseye OS

$ sudo apt-get install qtbase5-dev qtchooser
$ sudo apt-get install qt5-qmake qtbase5-dev-tools
$ sudo apt-get install qtcreator
$ sudo apt-get install qtdeclarative5-dev

(following this guide)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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