Issue with Nodejs onoff install - Is the help page outdated?



I have trouble setting up my Raspi3 (arm7) with blynk. Here is the sequence of what I have done, starting with a fresh Debian Stretch install.
$ sudo apt-get purge node nodejs node.js -y
$ sudo apt-get autoremove
$ url -sL | sudo -E bash -
Note: I use setup_11.x as setup_6.x is supposed to be for arm6 I believe (it doesn’t install npm in my case)
$ sudo apt-get update && sudo apt-get upgrade
$ sudo apt-get install build-essential nodejs -y
At this point I see that both node and npm are installed (respectively versions v11.6.0 & 6.5.0-next.0)
$ sudo npm install blynk-library -g
$ sudo npm install onoff -g // ==> this is where the pb occurs

The list of command is exactly what the help page is specifying but onoff doesn’t install (error messages are copied below). I also tried the “manual version” of install as specified in the help page. Same results.
Can somebody help ? (I also have the log file is needed)
Thanks much in advance.

gyp WARN EACCES user “root” does not have permission to access the dev dir “/root/.node-gyp/11.6.0”
gyp WARN EACCES attempting to reinstall using temporary dev dir “/usr/lib/node_modules/onoff/node_modules/epoll/.node-gyp”
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir ‘/usr/lib/node_modules/onoff/node_modules/epoll/.node-gyp’
gyp ERR! System Linux 4.14.79-v7+
gyp ERR! command “/usr/bin/node” “/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
gyp ERR! cwd /usr/lib/node_modules/onoff/node_modules/epoll
gyp ERR! node -v v11.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! errno 1
npm ERR! epoll@2.0.7 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the epoll@2.0.7 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-01-05T17_37_51_736Z-debug.log


More information:
When adding - -unsafe-perm to the line sudo npm install onoff, all the errors disappear but are replaced by a few warnings (see below). But apparently onoff is not correctly installed because blynk client keeps telling " No direct pin operations available. Maybe you need to install mraa or onoff modules?".
Thanks again for any hint on what the issue could be and how to fix it. I am really stuck…

List of warnings:
npm WARN saveError ENOENT: no such file or directory, open ‘/home/pi/package.json’
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open ‘/home/pi/package.json’
npm WARN pi No description
npm WARN pi No repository field.
npm WARN pi No README data
npm WARN pi No license field.


my order on my pi2 was a little different… might be worth trying .
even though the essentials is installed… i installed npm.

apt-get install npm
npm install -g blynk-library
npm install -g onoff


I tried to install npm (on top of what I had already, using sudo apt-get install npm) and re-install blynk-library and onoff (in sudo mode otherwise it wouldn’t install) and now when I press a button in the blynk app, the blynk client exits on an error (see below).

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
at maybeCallback (fs.js:135:9)
at Object.write (fs.js:536:16)
at Gpio.write (/usr/lib/node_modules/onoff/onoff.js:192:8)
at exports.BoardOnOff.process (/usr/lib/node_modules/blynk-library/blynk-node.js:367:13)
at Blynk.onReceive (/usr/lib/node_modules/blynk-library/blynk.js:481:29)
at exports.SslClient. (/usr/lib/node_modules/blynk-library/blynk.js:562:50)
at exports.SslClient.emit (events.js:188:13)
at TLSSocket. (/usr/lib/node_modules/blynk-library/blynk-node.js:212:16)
at TLSSocket.emit (events.js:188:13)
at addChunk (_stream_readable.js:288:12)


Looks like you made some headway.

Just to clarify, you’re running the sudo blynk-client <auth> command, or sudo node myproject.js command ?


blynk-client (but not in sudo)


It must be your node version (11).

I followed this instruction and really had no issues.

Sorry, im not going to be of much help.



I receive the exact same error.
I’ve tried installing with sudo. The I’ve tried as root.
I tried creating the metioned paths.
I tried chaging owner for the specified files, both with my current user and root.
Nothing works!

I also have no idea where to go to next :frowning:


Same error msg > so unable to install onoff package…
I tried with node 8, 10, 11 - which all install automatically npm
But onoff package always fails with similar listed msg
I‘m using the latest raspi3B - no way to get Blynk run

In paralllel I tried to install local Blynk server this works perfect


I spent a huge amount of time trying to fix this issue on my rpi 3, with no success.
Maybe we need to post an issue on github ?


Just ignore the missing onoff, as it is only used for direct pin manipulation in the App, and use virtual pins with any other GPIO library… I use pigpio with great success.

Here are some NodeJS examples