Syntax error when running Blynk.syncAll script

Blynk Library Version: 0.3.8
OS: Linux 4.4.15-v7+
Node: v4.2.1
NPM: v2.14.7
Device: RPi 3 +B
Internet Source: Wifi
Objective: To properly run blynk.syncAll script in terminal.
Current Coding Rank: Noob

After reading a few threads/topics on the blynk.syncAll function, I found the information on it here:

(http://docs.blynk.cc/#blynk-main-operations-state-syncing-for-hardware)

Furthermore, I followed the link from that section and ended up copying/pasting the script from

(https://github.com/blynkkk/blynk-library/blob/master/examples/More/Sync/Sync.ino)

into a file called syncall.js. I attempted running sudo js syncall.js in the terminal after saving the file but get this output:

pi@raspberrypi:~ $ sudo js syncall.js

/home/pi/syncall.js:1
(function (exports, require, module, _filename, __dirname) { #define BLYNKPR
^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
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)
at startup (node.js:119:16)
at node.js:906:3
pi@raspberrypi:~ $

It’s obvious to me that the first line of script, #define BLYNK_PRINT Serial, is catching onto something but I don’t know enough to know what that thing is. Any advice would be so appreciated. This is basically my last obstacle in my current mission and it sucks not knowing enough to overcome it.

I’m sorry to inform you, but you’re actually trying to mix JavaScript (Node.js) and C/C++ (Arduino) languages.
It just won’t work.
To get started with Blynk on Raspberry, we suggest you to get comfortable with simple Node.js examples first.

1 Like

Hey @vshymanskyy

Thank you for taking the time to address this matter. I’m familiar with the formatting/body of C/C++ languages but didn’t put the pieces together, mainly that the file I was saving was saved as a JavaScript format (.js) but that its contents were C/C++ in flavor. I’m not at all familiar with JavaScript bodies, so I will look into those examples you recommended.

Lastly, is it possible to run some sort of script on the Raspberry, whether it’s python or JavaScript, that mimics the function of the sync.ino file that you wrote? I’m just trying to ensure that my Raspberry Pi is synced at all times, especially if power goes out and reboot occurs. Otherwise the timer widget can be very hit or miss when it comes to reaching those high/low signals.