enocean-js / node-enocean

an enocean implementation for node.js
GNU General Public License v2.0
29 stars 14 forks source link

Code errors when running: node index.js #29

Closed nabbl closed 6 years ago

nabbl commented 7 years ago

Hi,

Code doesn't seem to work. I get syntax errors (at least on windows ...)

Code in question: index.js:

socket.on( "get-last-sensor-value" , async function( id ) {
            socket.emit("last-sensors-value", await this.getLastValues( id ) ) // returns info for one single sensor

memory.js

    app.getLastValues = async function(id){
        return await getLastData(id)
    }
Holger-Will commented 7 years ago

what node version and node-enocean version are you running?

nabbl commented 7 years ago

16 Aug 19:04:45 - [info] Node-RED version: v0.17.5 16 Aug 19:04:45 - [info] Node.js version: v6.9.4 node-enocean: 2.1.0

Holger-Will commented 7 years ago

ok, async await only works for node >= 7.6.0. before that, you have to start your project with the harmony flag...

node index.js --harmony-async-await

i should make this more clear in the read me, or set the min version acordingly...

btw, there is a 3.0.0beta of node enocean with a new generic eep decoder which in theory should be able to parse all eep's...it's not completely done but woks just great for simple telegram. Only some edge cases do break currently. You can install it with

npm i -S node-enocean@3
nabbl commented 7 years ago

I tried to install it like that. But it also tries to install a very old node-serialport version (and then tries gyp to recompile)

but this is with node 8.6.0 Maybe it would be a good idea anyway to update the serialport version to the newest one. Shouldn't be too much code change anyway.

Holger-Will commented 7 years ago

i just published version 3.0.1 (no beta tag) which uses serialport 4.x this works well with node 8.x, adds some new features and better error handling.

the problem with 5.x is that i use a third party serialport parser which does not work wth 5.x yet...

Holger-Will commented 7 years ago

leaving this open for a while for reference...

Holger-Will commented 7 years ago

request to support serialport 5.x https://github.com/RafaelKa/node-serialport-enocean-parser/issues/8

Jean-PhilippeD commented 6 years ago

Hello,

I have the same issue with async/await features not supported on node app I use which is release with node v6 version.

How could I do to have a compatibility ? I've trie the option --harmony-async-await but It seems to be an unknown option ?

node --harmony-async-await app.js 
node: bad option: --harmony-async-await
Holger-Will commented 6 years ago

this should no longer be an issue for current node versions...