11

I am trying to install node.js on my Raspberry Pi as well as GPIO.

I am running a brand new install of Debian Jessie

I could get nodejs v.0.10.29 installed. No matter what I do, this is pretty much the most recent package I have been able to install even if a lot of post I read are speaking of version 4.0.0.

However v0.10.29 is running and I could run a simple http server.

The problem comes when I try to install GPIO. I have tried the following;

  • rpi-gpio
  • pi-gpio
  • onoff

I can't get any of them to work and I have played around trying anything I could find on the web to fix it. I have tried pretty much everything.

So, since I probably messed up a lot of things, I reinstalled the OS Debian {Ed: Raspbian} Jessie and will give it another shot.

From there, what should I do after my OS is installed to get this to work?

Anyone have a good set of instruction for this - because I am probably missing something, right?

If anyone is willing to help I would gladly follow instructions and post any error messages I'm getting, because so far this is all I have been getting.

So I guess I will start with:

sudo apt-get update

What's next?

EDIT #1 Nodejs v0.10.29 is installed

I have installed Nodejs as suggested by Joan:

wget https://nodejs.org/dist/v4.3.1/node-v4.3.1-linux-armv6l.tar.xz
tar xf node-v4.3.1-linux-armv6l.tar.xz  
cd node-v4.3.1-linux-armv6l/ 
sudo cp -R * /usr/local

nodejs -v 

returned;

v0.10.29

EDIT#2 pi-gpio install

Now that node is installed I have try to turn a led on on pin 18 and got the following error;

module.js:340 
throw err; 
^ 
Error: Cannot find module 'pi-gpio' 
at Function.Module._resolveFilename (module.js:338:15) 
at Function.Module._load (module.js:280:25) 
at Module.require (module.js:364:17) 
at require (module.js:380:17) 
at Object.<anonymous> (/home/pi/NODE/http.js:22:12) 
at Module._compile (module.js:456:26) 
at Object.Module._extensions..js (module.js:474:10) 
at Module.load (module.js:356:32) 
at Function.Module._load (module.js:312:12) 
at Function.Module.runMain (module.js:497:10)

So I have installed pi-gpio using npm;

sudo npm install pi-gpio

I am now getting this error;

Error when trying to open pin 18
/bin/sh: 1: gpio-admin: not found

Error when trying to close pin 18
/bin/sh: 1: gpio-admin: not found

So I will now install gpio-admin.

And this where it get messy because gpio-admin is old and wont install on the Debian Jessie So if anyone can come up with a way to turn on a led from Nodejs under Debian Jessie that would be awesome.

2 Answers 2

7

For example to install RPi nodejs version 4.3.1 (see below for other versions)

wget https://nodejs.org/dist/v4.3.1/node-v4.3.1-linux-armv6l.tar.xz
tar xf node-v4.3.1-linux-armv6l.tar.xz  
cd node-v4.3.1-linux-armv6l/ 
sudo cp -R * /usr/local

Check installation with

node -v

Different versions are available from https://nodejs.org/dist/

For the Pi2B make sure you download a linux-arm7l build, for all other Pis make sure you download a linux-arm6l build.

10
  • Thank you will try that version. So far that distributor always returned me 404. Feb 22, 2016 at 18:18
  • Yeah I'm still getting a 404 response Feb 22, 2016 at 18:20
  • 1
    I followed those instructions just before I posted and have just repeated the wget without problem. Can you ping nodejs.org?
    – joan
    Feb 22, 2016 at 18:24
  • yes I can. Do I have to sudo wget? Feb 22, 2016 at 18:28
  • 1
    No, sudo is not required (it wouldn't give a 404 error). Make sure you cut&paste the wget line. You may prefer a later version. Look in nodejs.org/dist and make sure you download an arm6l version. I'm not sure if 6l will also work on a Pi2B.
    – joan
    Feb 22, 2016 at 18:32
2

Figured out how to get *GPIO* working with *Nodejs*.

Let me tell you that this was far from being Plug and play.

**OS** : *Raspbian Jessie*

**Nodejs**: *Version 4.3.1* ( Credit to joan)

Note that you should remove any old installation of *Nodejs*.

I have updated *npm* with the following command;

sudo npm install -g npm@latest

Then I have installed *gpio v0.2.7*;

 sudo npm install gpio

and got the folowing warning;

npm WARN enoent ENOENT: no such file or directory, open '/home/pi/package.json'

So I will have to deal with that.

Then I have installed *rpi-gpio*;

sudo npm install rpi-gpio

Still got the warning about package.json. At this point my script was working I could reach the server and my led light came on.

Other install I have made due to warning and errors:

sudo npm install graceful-fs@^4.0.0
sudo npm install node-gyp

I'm not sure that the last 2 installs where needed but it ended up working so you might want to try that to.

Your Answer

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

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