Very new to Raspberry Pi and Blynk. I have followed the instructions and have the correct modules loaded but,
When running blynk.js error returned :
pi@pool:~ $ blynk.js -token-
OnOff mode
fs.js:50
throw new
TypeError(’“options” must be a string or an object, got ’ +
^
TypeError: “options” must be a string or an object, got number
instead.
at getOptions (fs.js:50:11)
at fs.readFileSync
(fs.js:465:13)
at Array.map (native)
at exports.SslClient.connect
(/usr/lib/node_modules/blynk-library/blynk-node.js:169:42)
at doConnect
(/usr/lib/node_modules/blynk-library/blynk.js:544:15)
at Blynk.connect
(/usr/lib/node_modules/blynk-library/blynk.js:557:5)
at new Blynk
(/usr/lib/node_modules/blynk-library/blynk.js:385:10)
at Object.
(/usr/lib/node_modules/blynk-library/bin/blynk-client.js:10:13)
at Module._compile
(module.js:573:32)
at Object.Module._extensions…js
(module.js:582:10)
I can not find any reference to this error. Could someone please help?
Now v6.9.1 (I’d gone back to an even earlier version but after seeing your question went to 6.9.1). Which works fine.
As a completely unrelated aside, it is SO much easier to work Blynk with Arduino. As a non techie, I’m really struggling with the Pi. But Blynk is still the bomb. Thanks!
var blynkLib = require('blynk-library');
var sensorLib = require('node-dht-sensor');
var AUTH = '74b23f650d264189bddaa80be6262c8a';
// Setup Blynk
var blynk = new blynkLib.Blynk(AUTH);
// Setup sensor, exit if failed
var sensorType = 22; // 11 for DHT11, 22 for DHT22 and AM2302
var sensorPin = 4; // The GPIO pin number for sensor signal
if (!sensorLib.initialize(sensorType, sensorPin)) {
console.warn('Failed to initialize sensor');
process.exit(1);
}
// Automatically update sensor value every 2 seconds
setInterval(function() {
var readout = sensorLib.read();
blynk.virtualWrite(3, readout.temperature.toFixed(1));
blynk.virtualWrite(4, readout.humidity.toFixed(1));
console.log('Temperature:', readout.temperature.toFixed(1) + 'C');
console.log('Humidity: ', readout.humidity.toFixed(1) + '%');
}, 2000);
give me the same error . im using RASPBIAN JESSIE WITH PIXEL, raspberry pi 3, node 7.2.0 ( im downgrade to 7.1.0, 7.0.0) the error is :
OnOff mode
fs.js:50
throw new TypeError('"options" must be a string or an object, got ' +
^
TypeError: "options" must be a string or an object, got number instead.
at getOptions (fs.js:50:11)
at fs.readFileSync (fs.js:465:13)
at Array.map (native)
at exports.SslClient.connect (/usr/lib/node_modules/blynk-library/blynk-node.js:169:42)
at doConnect (/usr/lib/node_modules/blynk-library/blynk.js:544:15)
at Blynk.connect (/usr/lib/node_modules/blynk-library/blynk.js:557:5)
at new Blynk (/usr/lib/node_modules/blynk-library/blynk.js:385:10)
at Object.<anonymous> (/home/pi/test.js:7:13)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
for node <6.9.1 the error is :
pi@raspi:~ $ node test.js
module.js:597
return process.dlopen(module, path._makeLong(filename));
^
Error: Module version mismatch. Expected 48, got 51.
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/pi/test.js:2:17)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
root@DietPi:~# blynk.js xxxxxxxxxxxxxxxxxxxxxxxx
OnOff mode
fs.js:50
throw new TypeError(’“options” must be a string or an object, got ’ +
^
TypeError: “options” must be a string or an object, got number instead.
at getOptions (fs.js:50:11)
at fs.readFileSync (fs.js:465:13)
at Array.map (native)
at exports.SslClient.connect (/usr/local/lib/node_modules/blynk-library/blynk-node.js:169:42)
at doConnect (/usr/local/lib/node_modules/blynk-library/blynk.js:546:15)
at Blynk.connect (/usr/local/lib/node_modules/blynk-library/blynk.js:559:5)
at new Blynk (/usr/local/lib/node_modules/blynk-library/blynk.js:385:10)
at Object. (/usr/local/lib/node_modules/blynk-library/bin/blynk-client.js:10:13)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
/node_modules/blynk-library/blynk-node.js
find 169 line
if (self.ca) { opts.ca = self.ca.map(fs.readFileSync); }
and replace it with:
if (self.ca) {
opts.ca = [fs.readFileSync(self.ca[0])];
}
or
if (self.ca) {
opts.ca = self.ca.map(function(item){
fs.readFileSync(item)
});
}