Simple relay (node.js + Raspberry Pi)

Hi, Could anyone check what’s wrong with this code ?

[CODE]var BlynkLib = require(‘blynk-library’);

var blynk = new BlynkLib.Blynk(’***’);

var Gpio = require(‘onoff’).Gpio,
relay = new Gpio(21, ‘out’);

var button = new blynk.VirtualPin(1);

button.on(‘write’, function(param) {
console.log(‘V1:’, param);
relay.writeSync(param.toString());
});
[/CODE]
I know this isn’t necessary as the pin works out of the box , but I wanted to do more with the button press.

Bump
Can anyone help me please…

Well, it is hard to answer without understanding what is wrong. It is not compiled? Write function not invoked? Relay doesn’t get anything?

Sorry for that , didn’t realize I didn’t state the problem in the post.
Yes , the write function is not invoked,
however if I put the write function outside button.on it works.

Could you please post those code that works? (function outside button.on)

I mean if I don’t put write in the function the relay works properly.

relay.writeSync(1)